diff --git a/docs/ci/travis.rst b/docs/ci/travis.rst index 03a08b9d..e4dd6ef5 100644 --- a/docs/ci/travis.rst +++ b/docs/ci/travis.rst @@ -89,8 +89,8 @@ it), please use ``--lib="."`` option for :ref:`cmd_ci` command script: - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N -Library dependecies -~~~~~~~~~~~~~~~~~~~ +Library dependencies +~~~~~~~~~~~~~~~~~~~~ There 2 options to test source code with dependent libraries: diff --git a/platformio/__init__.py b/platformio/__init__.py index adf9961b..5c776f68 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0b6") +VERSION = (3, 0, "0b7") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" @@ -31,7 +31,6 @@ __license__ = "Apache Software License" __copyright__ = "Copyright 2014-present PlatformIO" __apiurl__ = "https://api.platformio.org" -__apiip__ = "198.7.57.247" if sys.version_info < (2, 7, 0) or sys.version_info >= (3, 0, 0): msg = ("PlatformIO version %s does not run under Python version %s.\n" diff --git a/platformio/util.py b/platformio/util.py index 0a55725a..88c5832f 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -26,8 +26,12 @@ from os.path import (abspath, basename, dirname, expanduser, isdir, isfile, from platform import system, uname from shutil import rmtree from threading import Thread +from time import sleep -from platformio import __apiip__, __apiurl__, __version__, exception +import click +import requests + +from platformio import __apiurl__, __version__, exception # pylint: disable=wrong-import-order try: @@ -357,20 +361,19 @@ def get_logicaldisks(): def get_request_defheaders(): - import requests data = (__version__, int(is_ci()), requests.utils.default_user_agent()) return {"User-Agent": "PlatformIO/%s CI/%d %s" % data} @memoized def _api_request_session(): - import requests return requests.Session() -def get_api_result(path, # pylint: disable=too-many-branches - params=None, data=None, skipdns=False): - import requests +def _get_api_result( + path, # pylint: disable=too-many-branches + params=None, + data=None): from platformio.app import get_setting result = None @@ -378,9 +381,6 @@ def get_api_result(path, # pylint: disable=too-many-branches headers = get_request_defheaders() url = __apiurl__ - if skipdns: - url = "https://%s" % __apiip__ - headers['host'] = __apiurl__[__apiurl__.index("://") + 3:] if get_setting("disable_ssl"): url = url.replace("https://", "http://") @@ -400,14 +400,6 @@ def get_api_result(path, # pylint: disable=too-many-branches raise exception.APIRequestError(result['errors'][0]['title']) else: raise exception.APIRequestError(e) - except (requests.exceptions.ConnectionError, - requests.exceptions.ConnectTimeout, - requests.exceptions.ReadTimeout): - if not skipdns: - return get_api_result(path, params, data, skipdns=True) - raise exception.APIRequestError( - "Could not connect to PlatformIO Registry Service. " - "Please try later.") except ValueError: raise exception.APIRequestError("Invalid response: %s" % r.text.encode("utf-8")) @@ -417,6 +409,26 @@ def get_api_result(path, # pylint: disable=too-many-branches return result +def get_api_result(path, params=None, data=None): + max_retries = 5 + total = 0 + while total < max_retries: + try: + return _get_api_result(path, params, data) + except (requests.exceptions.ConnectionError, + requests.exceptions.Timeout) as e: + total += 1 + click.secho( + "[API] ConnectionError: {0} (incremented retry: max={1}, " + "total={2})".format(e, max_retries, total), + fg="yellow") + sleep(2 * total) + + raise exception.APIRequestError( + "Could not connect to PlatformIO Registry Service. " + "Please try later.") + + @memoized def _lookup_frameworks(): frameworks = {} diff --git a/tests/commands/test_init.py b/tests/commands/test_init.py index 6064fd49..5f08c336 100644 --- a/tests/commands/test_init.py +++ b/tests/commands/test_init.py @@ -117,8 +117,8 @@ def test_init_special_board(clirunner, validate_cliresult): def test_init_enable_auto_uploading(clirunner, validate_cliresult): with clirunner.isolated_filesystem(): - result = clirunner.invoke(cmd_init, - ["-b", "uno", "--enable-auto-uploading"]) + result = clirunner.invoke( + cmd_init, ["-b", "uno", "--project-option", "targets=upload"]) validate_cliresult(result) validate_pioproject(getcwd()) config = util.load_project_config()