update get.py and add get.exe

- get.exe is clickable and will soon download binary form of esptool,
which will really simplify installation on Windows
- get.py does not require any extra modules on Linux and Mac
- ```pip install requests``` required only on Windows (if not using
get.exe)
- Paths are made relative to the file in order to make the windows
executable clickable.
This commit is contained in:
me-no-dev 2017-01-19 04:48:42 +02:00
parent 9e6e3249b6
commit 93d2bc7f1e
3 changed files with 26 additions and 20 deletions

View File

@ -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 && \ curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py && \
sudo python get-pip.py && \ sudo python get-pip.py && \
sudo pip install pyserial && \ sudo pip install pyserial && \
sudo pip install requests && \
mkdir -p ~/Documents/Arduino/hardware/espressif && \ mkdir -p ~/Documents/Arduino/hardware/espressif && \
cd ~/Documents/Arduino/hardware/espressif && \ cd ~/Documents/Arduino/hardware/espressif && \
git clone https://github.com/espressif/arduino-esp32.git esp32 && \ 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 && \ wget https://bootstrap.pypa.io/get-pip.py && \
sudo python get-pip.py && \ sudo python get-pip.py && \
sudo pip install pyserial && \ sudo pip install pyserial && \
sudo pip install requests && \
mkdir -p ~/Arduino/hardware/espressif && \ mkdir -p ~/Arduino/hardware/espressif && \
cd ~/Arduino/hardware/espressif && \ cd ~/Arduino/hardware/espressif && \
git clone https://github.com/espressif/arduino-esp32.git esp32 && \ git clone https://github.com/espressif/arduino-esp32.git esp32 && \

BIN
tools/get.exe Normal file

Binary file not shown.

View File

@ -15,14 +15,17 @@ import sys
import tarfile import tarfile
import zipfile import zipfile
import re import re
import requests
if sys.version_info[0] == 3: if sys.version_info[0] == 3:
from urllib.request import urlretrieve from urllib.request import urlretrieve
else: else:
# Not Python 3 - today, it is most likely to be Python 2 # Not Python 3 - today, it is most likely to be Python 2
from urllib import urlretrieve 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): def sha256sum(filename, blocksize=65536):
hash = hashlib.sha256() hash = hashlib.sha256()
@ -46,7 +49,8 @@ def report_progress(count, blockSize, totalSize):
def unpack(filename, destination): def unpack(filename, destination):
dirname = '' dirname = ''
print('Extracting {0}'.format(filename)) print('Extracting {0}'.format(os.path.basename(filename)))
sys.stdout.flush()
if filename.endswith('tar.gz'): if filename.endswith('tar.gz'):
tfile = tarfile.open(filename, 'r:gz') tfile = tarfile.open(filename, 'r:gz')
tfile.extractall(destination) tfile.extractall(destination)
@ -72,26 +76,26 @@ def get_tool(tool):
local_path = dist_dir + archive_name local_path = dist_dir + archive_name
url = tool['url'] url = tool['url']
#real_hash = tool['checksum'].split(':')[1] #real_hash = tool['checksum'].split(':')[1]
if not os.path.isfile(local_path):
print('Downloading ' + archive_name);
sys.stdout.flush()
if 'CYGWIN_NT' in sys_name: if 'CYGWIN_NT' in sys_name:
ctx = ssl.create_default_context() ctx = ssl.create_default_context()
ctx.check_hostname = False ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE ctx.verify_mode = ssl.CERT_NONE
if not os.path.isfile(local_path):
print('Downloading ' + archive_name);
if 'CYGWIN_NT' in sys_name:
urlretrieve(url, local_path, report_progress, context=ctx) urlretrieve(url, local_path, report_progress, context=ctx)
else: elif 'Windows' in sys_name:
try:
urlretrieve(url, local_path, report_progress)
except Exception,e:
r = requests.get(url) r = requests.get(url)
f = open(local_path, 'wb') f = open(local_path, 'wb')
f.write(r.content) f.write(r.content)
f.close() f.close()
else:
urlretrieve(url, local_path, report_progress)
sys.stdout.write("\rDone\n") sys.stdout.write("\rDone\n")
sys.stdout.flush() sys.stdout.flush()
else: else:
print('Tool {0} already downloaded'.format(archive_name)) print('Tool {0} already downloaded'.format(archive_name))
sys.stdout.flush()
#local_hash = sha256sum(local_path) #local_hash = sha256sum(local_path)
#if local_hash != real_hash: #if local_hash != real_hash:
# print('Hash mismatch for {0}, delete the file and try again'.format(local_path)) # 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: if sys.maxsize > 2**32:
bits = 64 bits = 64
sys_name = platform.system() 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' sys_name = 'LinuxARM'
if 'CYGWIN_NT' in sys_name: if 'CYGWIN_NT' in sys_name:
sys_name = 'Windows' sys_name = 'Windows'
return arduino_platform_names[sys_name][bits] return arduino_platform_names[sys_name][bits]
if __name__ == '__main__': if __name__ == '__main__':
print('Platform: {0}'.format(identify_platform())) identified_platform = identify_platform()
tools_to_download = load_tools_list('../package/package_esp32_index.template.json', 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) mkdir_p(dist_dir)
for tool in tools_to_download: for tool in tools_to_download:
get_tool(tool) get_tool(tool)
print('Done')