diff --git a/README.md b/README.md index fe5b241eed9d56be6fd5b9cc745083cbae9b71bc..9d95f9bb201425f350e81045495177d5de23668f 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,6 @@ Most of the framework is implemented. Most noticable is the missing analogWrite. curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py && \ sudo python get-pip.py && \ sudo pip install pyserial && \ - sudo pip install requests && \ mkdir -p ~/Documents/Arduino/hardware/espressif && \ cd ~/Documents/Arduino/hardware/espressif && \ git clone https://github.com/espressif/arduino-esp32.git esp32 && \ @@ -52,7 +51,6 @@ Most of the framework is implemented. Most noticable is the missing analogWrite. wget https://bootstrap.pypa.io/get-pip.py && \ sudo python get-pip.py && \ sudo pip install pyserial && \ - sudo pip install requests && \ mkdir -p ~/Arduino/hardware/espressif && \ cd ~/Arduino/hardware/espressif && \ git clone https://github.com/espressif/arduino-esp32.git esp32 && \ diff --git a/tools/get.exe b/tools/get.exe new file mode 100644 index 0000000000000000000000000000000000000000..eb618bf51f55b1116317fec7d078c281c4b8b9a0 Binary files /dev/null and b/tools/get.exe differ diff --git a/tools/get.py b/tools/get.py index b3ed1cc51bf3f0bcf01858bb4c35875dfc0cd07d..fe9c8ea98e9f4e5282c2bf8ed12ca6222fc5c6c9 100755 --- a/tools/get.py +++ b/tools/get.py @@ -15,14 +15,17 @@ import sys import tarfile import zipfile import re -import requests if sys.version_info[0] == 3: from urllib.request import urlretrieve else: # Not Python 3 - today, it is most likely to be Python 2 from urllib import urlretrieve -dist_dir = 'dist/' +if 'Windows' in platform.system(): + import requests + +current_dir = os.path.dirname(os.path.realpath(__file__)) +dist_dir = current_dir + '/dist/' def sha256sum(filename, blocksize=65536): hash = hashlib.sha256() @@ -46,7 +49,8 @@ def report_progress(count, blockSize, totalSize): def unpack(filename, destination): dirname = '' - print('Extracting {0}'.format(filename)) + print('Extracting {0}'.format(os.path.basename(filename))) + sys.stdout.flush() if filename.endswith('tar.gz'): tfile = tarfile.open(filename, 'r:gz') tfile.extractall(destination) @@ -72,26 +76,26 @@ def get_tool(tool): local_path = dist_dir + archive_name url = tool['url'] #real_hash = tool['checksum'].split(':')[1] - if 'CYGWIN_NT' in sys_name: - ctx = ssl.create_default_context() - ctx.check_hostname = False - ctx.verify_mode = ssl.CERT_NONE if not os.path.isfile(local_path): print('Downloading ' + archive_name); + sys.stdout.flush() if 'CYGWIN_NT' in sys_name: - urlretrieve(url, local_path, report_progress,context=ctx) + ctx = ssl.create_default_context() + ctx.check_hostname = False + ctx.verify_mode = ssl.CERT_NONE + urlretrieve(url, local_path, report_progress, context=ctx) + elif 'Windows' in sys_name: + r = requests.get(url) + f = open(local_path, 'wb') + f.write(r.content) + f.close() else: - try: - urlretrieve(url, local_path, report_progress) - except Exception,e: - r = requests.get(url) - f = open(local_path, 'wb') - f.write(r.content) - f.close() + urlretrieve(url, local_path, report_progress) sys.stdout.write("\rDone\n") sys.stdout.flush() else: print('Tool {0} already downloaded'.format(archive_name)) + sys.stdout.flush() #local_hash = sha256sum(local_path) #if local_hash != real_hash: # print('Hash mismatch for {0}, delete the file and try again'.format(local_path)) @@ -117,15 +121,19 @@ def identify_platform(): if sys.maxsize > 2**32: bits = 64 sys_name = platform.system() - if 'Linux' in sys_name and platform.platform().find('arm') > 0: + sys_platform = platform.platform() + print('System: %s, Info: %s' % (sys_name, sys_platform)) + if 'Linux' in sys_name and sys_platform.find('arm') > 0: sys_name = 'LinuxARM' if 'CYGWIN_NT' in sys_name: sys_name = 'Windows' return arduino_platform_names[sys_name][bits] if __name__ == '__main__': - print('Platform: {0}'.format(identify_platform())) - tools_to_download = load_tools_list('../package/package_esp32_index.template.json', identify_platform()) + identified_platform = identify_platform() + print('Platform: {0}'.format(identified_platform)) + tools_to_download = load_tools_list(current_dir + '/../package/package_esp32_index.template.json', identified_platform) mkdir_p(dist_dir) for tool in tools_to_download: get_tool(tool) + print('Done')