New standalone (1-script) PlatformIO Core Installer

This commit is contained in:
Ivan Kravets
2020-03-19 18:26:30 +02:00
parent 24a0d9123e
commit 15647c81f0
3 changed files with 11 additions and 11 deletions

View File

@ -27,6 +27,7 @@ PlatformIO Core 4
- Send a text to device on ENTER with ``send_on_enter`` filter (`issue #926 <https://github.com/platformio/platformio-core/issues/926>`_)
- Show a hexadecimal representation of the data (code point of each character) with ``hexlify`` filter
* New standalone (1-script) `PlatformIO Core Installer <https://github.com/platformio/platformio-core-installer>`_
* Initial support for `Renode <https://docs.platformio.org/page/plus/debug-tools/qemu.html>`__ simulation framework (`issue #3401 <https://github.com/platformio/platformio-core/issues/3401>`_)
* Added support for Arm Mbed "module.json" ``dependencies`` field (`issue #3400 <https://github.com/platformio/platformio-core/issues/3400>`_)
* Improved support for Arduino "library.properties" ``depends`` field

2
docs

Submodule docs updated: 1f61513892...0af3f53030

View File

@ -17,7 +17,7 @@ import io
import sys
import subprocess
NEW_SCRIPT_URL = "https://raw.githubusercontent.com/platformio/platformio-core-installer/develop/get-platformio.py"
MAIN_SCRIPT_URL = "https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py"
def download_with_requests(url, dst):
@ -33,10 +33,11 @@ def download_with_requests(url, dst):
def download_with_urllib3(url, dst):
import urllib3
http = urllib3.PoolManager()
r = http.request('GET', url, preload_content=False)
with open(dst, 'wb') as out:
http = urllib3.PoolManager()
r = http.request("GET", url, preload_content=False)
with open(dst, "wb") as out:
while True:
data = r.read(io.DEFAULT_BUFFER_SIZE)
if not data:
@ -55,7 +56,7 @@ def download_with_urllib(url, dst):
response = urlopen(url)
CHUNK = 16 * 1024
with open(dst, 'wb') as f:
with open(dst, "wb") as f:
while True:
chunk = response.read(CHUNK)
if not chunk:
@ -81,7 +82,7 @@ def download_file(url, dst):
download_with_urllib3,
download_with_urllib,
download_with_curl,
download_with_wget
download_with_wget,
]
for method in methods:
try:
@ -89,14 +90,12 @@ def download_file(url, dst):
return dst
except:
pass
raise Exception("Could not download file '%s' to '%s' "%(url, dst))
raise Exception("Could not download file '%s' to '%s' " % (url, dst))
def main():
print("This installer script is deprecated and will be removed in the next release. Please use %s" %
NEW_SCRIPT_URL)
with tempfile.NamedTemporaryFile() as tmp_file:
dst = download_file(NEW_SCRIPT_URL, str(tmp_file.name))
dst = download_file(MAIN_SCRIPT_URL, str(tmp_file.name))
command = [sys.executable, dst]
command.extend(sys.argv[1:])
subprocess.check_call(command)