forked from platformio/platformio-core
Merge branch 'feature/prepend-python-pioplus' into develop
This commit is contained in:
@ -15,6 +15,7 @@
|
|||||||
from email.utils import parsedate_tz
|
from email.utils import parsedate_tz
|
||||||
from math import ceil
|
from math import ceil
|
||||||
from os.path import getsize, join
|
from os.path import getsize, join
|
||||||
|
from sys import version_info
|
||||||
from time import mktime
|
from time import mktime
|
||||||
|
|
||||||
import click
|
import click
|
||||||
@ -30,9 +31,13 @@ class FileDownloader(object):
|
|||||||
CHUNK_SIZE = 1024
|
CHUNK_SIZE = 1024
|
||||||
|
|
||||||
def __init__(self, url, dest_dir=None):
|
def __init__(self, url, dest_dir=None):
|
||||||
|
self._request = None
|
||||||
# make connection
|
# make connection
|
||||||
self._request = requests.get(
|
self._request = requests.get(
|
||||||
url, stream=True, headers=util.get_request_defheaders())
|
url,
|
||||||
|
stream=True,
|
||||||
|
headers=util.get_request_defheaders(),
|
||||||
|
verify=version_info >= (2, 7, 9))
|
||||||
if self._request.status_code != 200:
|
if self._request.status_code != 200:
|
||||||
raise FDUnrecognizedStatusCode(self._request.status_code, url)
|
raise FDUnrecognizedStatusCode(self._request.status_code, url)
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from os.path import join
|
from os.path import dirname, join
|
||||||
|
|
||||||
from platformio import __version__, exception, util
|
from platformio import __version__, exception, util
|
||||||
from platformio.managers.package import PackageManager
|
from platformio.managers.package import PackageManager
|
||||||
@ -100,7 +100,10 @@ def pioplus_call(args, **kwargs):
|
|||||||
sys.version.split()[0]))
|
sys.version.split()[0]))
|
||||||
|
|
||||||
pioplus_path = join(get_core_package_dir("tool-pioplus"), "pioplus")
|
pioplus_path = join(get_core_package_dir("tool-pioplus"), "pioplus")
|
||||||
os.environ['PYTHONEXEPATH'] = util.get_pythonexe_path()
|
pythonexe_path = util.get_pythonexe_path()
|
||||||
|
os.environ['PATH'] = (os.pathsep).join(
|
||||||
|
[dirname(pythonexe_path), os.environ['PATH']])
|
||||||
|
os.environ['PYTHONEXEPATH'] = pythonexe_path
|
||||||
os.environ['PYTHONPYSITEDIR'] = get_core_package_dir("pysite-pioplus")
|
os.environ['PYTHONPYSITEDIR'] = get_core_package_dir("pysite-pioplus")
|
||||||
util.copy_pythonpath_to_osenv()
|
util.copy_pythonpath_to_osenv()
|
||||||
code = subprocess.call([pioplus_path] + args, **kwargs)
|
code = subprocess.call([pioplus_path] + args, **kwargs)
|
||||||
|
@ -504,7 +504,7 @@ def _get_api_result(
|
|||||||
|
|
||||||
result = None
|
result = None
|
||||||
r = None
|
r = None
|
||||||
disable_ssl_check = sys.version_info < (2, 7, 9)
|
verify_ssl = sys.version_info >= (2, 7, 9)
|
||||||
|
|
||||||
headers = get_request_defheaders()
|
headers = get_request_defheaders()
|
||||||
if not url.startswith("http"):
|
if not url.startswith("http"):
|
||||||
@ -520,14 +520,14 @@ def _get_api_result(
|
|||||||
data=data,
|
data=data,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
auth=auth,
|
auth=auth,
|
||||||
verify=not disable_ssl_check)
|
verify=verify_ssl)
|
||||||
else:
|
else:
|
||||||
r = _api_request_session().get(
|
r = _api_request_session().get(
|
||||||
url,
|
url,
|
||||||
params=params,
|
params=params,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
auth=auth,
|
auth=auth,
|
||||||
verify=not disable_ssl_check)
|
verify=verify_ssl)
|
||||||
result = r.json()
|
result = r.json()
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
except requests.exceptions.HTTPError as e:
|
except requests.exceptions.HTTPError as e:
|
||||||
|
Reference in New Issue
Block a user