diff --git a/tools/test/.gitignore b/tools/test/.gitignore index 378eac2..5d0d475 100644 --- a/tools/test/.gitignore +++ b/tools/test/.gitignore @@ -1 +1,4 @@ build +cache +libraries +library_index.json diff --git a/tools/test/parse_library.py b/tools/test/parse_library.py new file mode 100644 index 0000000..52471e9 --- /dev/null +++ b/tools/test/parse_library.py @@ -0,0 +1,36 @@ +import json +import os.path +import urllib2 +import time +import urllib +import zipfile + +urllib.urlretrieve ("http://downloads.arduino.cc/libraries/library_index.json", "library_index.json") + +with open('library_index.json') as file: + data = json.load(file) + +libraries = {} + +for library in data["libraries"]: + libraries[library["name"]] = library + +for name, library in libraries.iteritems(): + + zip_file = os.path.basename(library["url"]) + download_file = "cache/" + zip_file + + print zip_file + + if not os.path.exists(download_file): + try: + urllib.urlretrieve (library["url"], download_file) + except Exception, e: + print e + time.sleep(1) + try: + zip_ref = zipfile.ZipFile(download_file, 'r') + zip_ref.extractall('libraries') + zip_ref.close() + except Exception, e: + print e \ No newline at end of file