Skip to content

Commit d2ba58d

Browse files
author
Adafruit Adabot
committed
check if the library is in the arduino lib manager
1 parent 40d755c commit d2ba58d

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

adabot/arduino_libraries.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
file_data = []
4141

4242
all_libraries = []
43+
adafruit_library_index = []
4344

4445
def list_repos():
4546
""" Return a list of all Adafruit repositories with 'Arduino' in either the
@@ -109,7 +110,7 @@ def validate_library_properties(repo):
109110
release_tag = None
110111
lib_prop_file = requests.get("https://raw.githubusercontent.com/adafruit/" + repo["name"] + "/master/library.properties")
111112
if not lib_prop_file.ok:
112-
print("{} skipped".format(repo["name"]))
113+
#print("{} skipped".format(repo["name"]))
113114
return None # no library properties file!
114115

115116
lines = lib_prop_file.text.split("\n")
@@ -179,6 +180,7 @@ def run_arduino_lib_checks():
179180
output_handler("Found {} Arduino libraries to check\n".format(len(repo_list)))
180181
failed_lib_prop = [[" Repo", "Release Tag", "library.properties Version"], [" ----", "-----------", "--------------------------"]]
181182
needs_release_list = [[" Repo", "Latest Release", "Commits Behind"], [" ----", "--------------", "--------------"]]
183+
needs_registration_list = [[" Repo"], [" ----"]]
182184
missing_travis_list = [[" Repo"], [" ----"]]
183185
missing_library_properties_list = [[" Repo"], [" ----"]]
184186

@@ -189,12 +191,23 @@ def run_arduino_lib_checks():
189191
continue
190192

191193
entry = {'name': repo["name"]}
192-
194+
193195
lib_check = validate_library_properties(repo)
194196
if not lib_check:
195197
missing_library_properties_list.append([" " + str(repo["name"])])
196198
continue
197199

200+
#print(repo['clone_url'])
201+
needs_registration = False
202+
for lib in adafruit_library_index:
203+
if (repo['clone_url'] == lib['repository']) or (repo['html_url'] == lib['website']):
204+
entry['arduino_version'] = lib['version'] # found it!
205+
break
206+
else:
207+
needs_registration = True
208+
if needs_registration:
209+
needs_registration_list.append([" " + str(repo["name"])])
210+
198211
entry['release'] = lib_check[0]
199212
entry['version'] = lib_check[1]
200213
repo['tag_name'] = lib_check[0]
@@ -217,6 +230,9 @@ def run_arduino_lib_checks():
217230
if len(failed_lib_prop) > 2:
218231
print_list_output("Libraries Have Mismatched Release Tag and library.properties Version: ({})", failed_lib_prop)
219232

233+
if len(needs_registration_list) > 2:
234+
print_list_output("Libraries that are not registered with Arduino: ({})", needs_registration_list)
235+
220236
if len(needs_release_list) > 2:
221237
print_list_output("Libraries have commits since last release: ({})", needs_release_list);
222238

@@ -232,8 +248,15 @@ def run_arduino_lib_checks():
232248
verbosity = cmd_line_args.verbose
233249
if cmd_line_args.output_file:
234250
output_filename = cmd_line_args.output_file
235-
236251
try:
252+
reply = requests.get("http://downloads.arduino.cc/libraries/library_index.json")
253+
if not reply.ok:
254+
print("Could not fetch http://downloads.arduino.cc/libraries/library_index.json")
255+
exit()
256+
arduino_library_index = reply.json()
257+
for lib in arduino_library_index['libraries']:
258+
if 'adafruit' in lib['url']:
259+
adafruit_library_index.append(lib)
237260
run_arduino_lib_checks()
238261
except:
239262
if output_filename is not None:

0 commit comments

Comments
 (0)