From 578dfa40aa76c8eb8b35277f0277a74f039feecb Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 2 Aug 2017 22:16:41 +0300 Subject: [PATCH 001/211] Ignore only C/C++ properties for VSCode extension --- platformio/ide/tpls/vscode/.gitignore.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/ide/tpls/vscode/.gitignore.tpl b/platformio/ide/tpls/vscode/.gitignore.tpl index 08e91a14..f39f7c9b 100644 --- a/platformio/ide/tpls/vscode/.gitignore.tpl +++ b/platformio/ide/tpls/vscode/.gitignore.tpl @@ -1,3 +1,3 @@ .pioenvs .piolibdeps -.vscode +.vscode/c_cpp_properties.json From bbcc79208c53d795b565fcc58fe3ec7e064569da Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 2 Aug 2017 22:17:21 +0300 Subject: [PATCH 002/211] Bump version to 3.5.0a1 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 6e3f3cc4..c5b55be2 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 4, 1) +VERSION = (3, 5, "0a1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 327d42d02d14d30bff8099229f1581ab28471ba7 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 3 Aug 2017 16:56:25 +0300 Subject: [PATCH 003/211] Sync docs --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index ebd68b4b..073eb483 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit ebd68b4bac5ea3dcb526637dce1f782cc2ce570d +Subproject commit 073eb483fb41fcce5514290b8e8359dda09696b3 From 351aaa3974154635a6731c6799f45c740312239d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 5 Aug 2017 19:19:43 +0300 Subject: [PATCH 004/211] Sync submodules --- docs | 2 +- examples | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs b/docs index 073eb483..9f566b96 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 073eb483fb41fcce5514290b8e8359dda09696b3 +Subproject commit 9f566b9657503ae664e031cc91d6b9a2193714b4 diff --git a/examples b/examples index a2d7ba27..59660b1f 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit a2d7ba27c3f2730381d99e587837c6aca9269e33 +Subproject commit 59660b1fe778bce4114f08b3be723174ebfecc6f From 5f320cc5c89115d8075114bc5e3ffab4eded2e2f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 7 Aug 2017 17:38:05 +0300 Subject: [PATCH 005/211] Introduce PIO Home --- platformio/commands/home.py | 27 +++++++++++++++++++++++++++ platformio/maintenance.py | 2 +- platformio/managers/core.py | 5 +++-- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 platformio/commands/home.py diff --git a/platformio/commands/home.py b/platformio/commands/home.py new file mode 100644 index 00000000..328298e9 --- /dev/null +++ b/platformio/commands/home.py @@ -0,0 +1,27 @@ +# Copyright (c) 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys + +import click + +from platformio.managers.core import pioplus_call + + +@click.command("home", short_help="PIO Home") +@click.option( + "--port", "-p", type=int, default=8008, help="HTTP port, default=8008") +@click.option("--no-open", is_flag=True) +def cli(*args, **kwargs): # pylint: disable=unused-argument + pioplus_call(sys.argv[1:]) diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 3e198f08..db4ac275 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -98,7 +98,7 @@ class Upgrader(object): self._upgrade_to_3_0_0), (semantic_version.Version("3.0.0-b.11"), self._upgrade_to_3_0_0b11), - (semantic_version.Version("3.4.0-a.9"), + (semantic_version.Version("3.5.0-a.2"), self._update_dev_platforms)] def run(self, ctx): diff --git a/platformio/managers/core.py b/platformio/managers/core.py index b052c23e..b9dae1d4 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -21,8 +21,9 @@ from platformio import __version__, exception, util from platformio.managers.package import PackageManager CORE_PACKAGES = { - "pysite-pioplus": ">=0.3.0,<2", - "tool-pioplus": ">=0.9.1,<2", + "contrib-piohome": "<2", + "pysite-pioplus": ">=0.4.2,<2", + "tool-pioplus": ">=0.10.0,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" } From 470041959051925b0d12fde207618191a59061e1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 7 Aug 2017 17:38:21 +0300 Subject: [PATCH 006/211] Bump version to 3.5.0a2 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index c5b55be2..33a56749 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a1") +VERSION = (3, 5, "0a2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From c05e1f7c9bcf97ba7700da9f8ee30352bb5a8a32 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 7 Aug 2017 19:33:13 +0300 Subject: [PATCH 007/211] Ignore missed packages in new development platform --- platformio/managers/platform.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index dec4bd30..6497b00f 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -113,20 +113,21 @@ class PlatformManager(BasePkgManager): pkg_dir = self.get_package_dir(name, requirements, url) p = PlatformFactory.newPlatform(pkg_dir) - pkgs_before = pkgs_after = p.get_installed_packages().keys() + pkgs_before = p.get_installed_packages().keys() + missed_pkgs = set() if not only_packages: BasePkgManager.update(self, pkg_dir, requirements, only_check) p = PlatformFactory.newPlatform(pkg_dir) - pkgs_after = p.get_installed_packages().keys() + missed_pkgs = set(pkgs_before) & set(p.packages.keys()) + missed_pkgs -= set(p.get_installed_packages().keys()) p.update_packages(only_check) self.cleanup_packages(p.packages.keys()) - pkgs_missed = set(pkgs_before) - set(pkgs_after) - if pkgs_missed: + if missed_pkgs: p.install_packages( - with_packages=pkgs_missed, skip_default_package=True) + with_packages=list(missed_pkgs), skip_default_package=True) return True From 51ff2b65f49c558ad37cd6fd5bdac8cecf4a8cb6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 8 Aug 2017 14:44:25 +0300 Subject: [PATCH 008/211] Bump version to 3.5.0a3 --- platformio/__init__.py | 2 +- platformio/managers/core.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 33a56749..f2b9947a 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a2") +VERSION = (3, 5, "0a3") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/managers/core.py b/platformio/managers/core.py index b9dae1d4..09ba478c 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -21,9 +21,9 @@ from platformio import __version__, exception, util from platformio.managers.package import PackageManager CORE_PACKAGES = { - "contrib-piohome": "<2", + "contrib-piohome": ">=0.1.2,<2", "pysite-pioplus": ">=0.4.2,<2", - "tool-pioplus": ">=0.10.0,<2", + "tool-pioplus": ">=0.10.1,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" } From 6bf42f90ed7248633db8345c89127de3f6d5a521 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 9 Aug 2017 17:59:28 +0300 Subject: [PATCH 009/211] Docs: Short titles in menu --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 9f566b96..a9599648 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 9f566b9657503ae664e031cc91d6b9a2193714b4 +Subproject commit a9599648a50e8badd31cd905058fd4df38873d5c From d913fb560037ddd4fe660bb5a4d4f5c061e39e6f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 9 Aug 2017 23:02:33 +0300 Subject: [PATCH 010/211] Call pip as module --- scripts/get-platformio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/get-platformio.py b/scripts/get-platformio.py index d9abf5d5..a297a803 100644 --- a/scripts/get-platformio.py +++ b/scripts/get-platformio.py @@ -112,7 +112,7 @@ def install_pip(): def install_platformio(): r = None - cmd = ["pip", "install", "-U", "platformio"] + cmd = ["python", "-m", "pip", "install", "-U", "platformio"] # cmd = [ # "pip", "install", "-U", # "https://github.com/platformio/platformio-core/archive/develop.zip" From 9b2e7bf927695f5b8d9e131613a43732035a6470 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 9 Aug 2017 23:43:31 +0300 Subject: [PATCH 011/211] Fix broken installer script --- scripts/get-platformio.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/get-platformio.py b/scripts/get-platformio.py index a297a803..357d47aa 100644 --- a/scripts/get-platformio.py +++ b/scripts/get-platformio.py @@ -92,6 +92,10 @@ def exec_python_cmd(args): def install_pip(): + r = exec_python_cmd(["-m", "pip", "--version"]) + if r['returncode'] == 0: + print r['out'] + return try: from urllib2 import urlopen except ImportError: @@ -112,9 +116,9 @@ def install_pip(): def install_platformio(): r = None - cmd = ["python", "-m", "pip", "install", "-U", "platformio"] + cmd = ["-m", "pip", "install", "-U", "platformio"] # cmd = [ - # "pip", "install", "-U", + # "-m", "pip", "install", "-U", # "https://github.com/platformio/platformio-core/archive/develop.zip" # ] try: From 2cb7fcca9adfb7ecd7162559d91e4dcd2d644db8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 10 Aug 2017 16:04:51 +0300 Subject: [PATCH 012/211] Bump version to 3.5.0a4 --- platformio/__init__.py | 2 +- platformio/managers/core.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index f2b9947a..f6142d3c 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a3") +VERSION = (3, 5, "0a4") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/managers/core.py b/platformio/managers/core.py index 09ba478c..66109093 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -23,7 +23,7 @@ from platformio.managers.package import PackageManager CORE_PACKAGES = { "contrib-piohome": ">=0.1.2,<2", "pysite-pioplus": ">=0.4.2,<2", - "tool-pioplus": ">=0.10.1,<2", + "tool-pioplus": ">=0.10.2,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" } From fd56e5cec9853f9ee6747a60d69cfc1b2da6e9dd Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 12 Aug 2017 19:16:36 +0300 Subject: [PATCH 013/211] Docs: New boards, typo fixes --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index a9599648..4013603d 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit a9599648a50e8badd31cd905058fd4df38873d5c +Subproject commit 4013603d3f01038d4d52add5f4ff7503034365c0 From 4a7cd5be6ab4d1e16cca8d5b07c9f3d9923794ec Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 13 Aug 2017 00:08:49 +0300 Subject: [PATCH 014/211] Update docs for VSCode --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 4013603d..153cf9d4 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 4013603d3f01038d4d52add5f4ff7503034365c0 +Subproject commit 153cf9d4b6ffcdfedc68a657496498a6075fe406 From d7d66fd4a6fd45ad0f0a2fa078c885a693ab8e65 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 14 Aug 2017 15:27:12 +0300 Subject: [PATCH 015/211] Improve fetching logical disks --- platformio/util.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/platformio/util.py b/platformio/util.py index f5a7b830..12a0f5be 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -429,19 +429,29 @@ def get_serialports(filter_hwid=False): def get_logicaldisks(): disks = [] if platform.system() == "Windows": - result = exec_command( - ["wmic", "logicaldisk", "get", "name,VolumeName"]).get("out", "") - disknamere = re.compile(r"^([A-Z]{1}\:)\s*(\S+)?") - for line in result.split("\n"): - match = disknamere.match(line.strip()) - if not match: - continue - disks.append({"disk": match.group(1), "name": match.group(2)}) + try: + result = exec_command( + ["wmic", "logicaldisk", "get", "name,VolumeName"]).get( + "out", "") + disknamere = re.compile(r"^([A-Z]{1}\:)\s*(\S+)?") + for line in result.split("\n"): + match = disknamere.match(line.strip()) + if not match: + continue + disks.append({"disk": match.group(1), "name": match.group(2)}) + return disks + except WindowsError: # pylint: disable=undefined-variable + pass + # try "fsutil" + result = exec_command(["fsutil", "fsinfo", "drives"]).get("out", "") + for disk in re.findall(r"[A-Z]:\\", result): + disks.append({"disk": disk[:-1], "name": disk}) + return disks else: result = exec_command(["df"]).get("out") - disknamere = re.compile(r"\d+\%\s+([a-z\d\-_/]+)$", flags=re.I) + disknamere = re.compile(r"^/.+\d+\%\s+([a-z\d\-_/]+)$", flags=re.I) for line in result.split("\n"): - match = disknamere.search(line.strip()) + match = disknamere.match(line.strip()) if not match: continue disks.append({ From 3229933ed039ee88b881ebf3ce66bac06616f1e6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 14 Aug 2017 23:58:12 +0300 Subject: [PATCH 016/211] Minor improvements --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 153cf9d4..f2a7f5ef 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 153cf9d4b6ffcdfedc68a657496498a6075fe406 +Subproject commit f2a7f5efcbbd8db1b2f6eb87a9a0b14a843ddf54 From 3d5114655fb5274a2c70a4bf65297e84f3f5f4f6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 15 Aug 2017 19:33:35 +0300 Subject: [PATCH 017/211] Docs: Embedded Testing with PlatformIO - Part 2 --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index f2a7f5ef..09dde9de 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit f2a7f5efcbbd8db1b2f6eb87a9a0b14a843ddf54 +Subproject commit 09dde9de11fec71f9df931575542089870c6914a From 541993c06bc62d52842f0397ca4052fa3254c573 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 15 Aug 2017 22:57:20 +0300 Subject: [PATCH 018/211] Implement throttle for API calls --- platformio/util.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/platformio/util.py b/platformio/util.py index 12a0f5be..07b2b33d 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -23,12 +23,13 @@ import stat import subprocess import sys from contextlib import contextmanager +from functools import wraps from glob import glob from os.path import (abspath, basename, dirname, expanduser, isdir, isfile, join, normpath, splitdrive) from shutil import rmtree from threading import Thread -from time import sleep +from time import sleep, time import click import requests @@ -149,6 +150,25 @@ class memoized(object): self.cache = {} +class throttle(object): + + def __init__(self, limit): + self.limit = limit # milliseconds + self.last = 0 + + def __call__(self, fn): + + @wraps(fn) + def wrapper(*args, **kwargs): + diff = int(round((time() - self.last) * 1000)) + if diff < self.limit: + sleep((self.limit - diff) * 0.001) + self.last = time() + return fn(*args, **kwargs) + + return wrapper + + def singleton(cls): """ From PEP-318 http://www.python.org/dev/peps/pep-0318/#examples """ _instances = {} @@ -336,8 +356,8 @@ def parse_conf_multi_values(items): ] -def change_filemtime(path, time): - os.utime(path, (time, time)) +def change_filemtime(path, mtime): + os.utime(path, (mtime, mtime)) def is_ci(): @@ -471,6 +491,7 @@ def _api_request_session(): return requests.Session() +@throttle(500) def _get_api_result( url, # pylint: disable=too-many-branches params=None, From e60e076d16919866b2337c883c4a7dc0a717ad4b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 16 Aug 2017 15:10:56 +0300 Subject: [PATCH 019/211] Better explanation about `lib_extra_dirs` --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 09dde9de..c3dc1fa9 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 09dde9de11fec71f9df931575542089870c6914a +Subproject commit c3dc1fa9bfe03c7f928ffae4ba45b7ebd5dacbe9 From 3f13821c431bbc521c83b5ccdfeaa7fd4ddc109a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 16 Aug 2017 15:12:45 +0300 Subject: [PATCH 020/211] Update history --- HISTORY.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index ad714683..d076ce7a 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,12 @@ Release Notes PlatformIO 3.0 -------------- +3.5.0 (2017-??-??) + +* PIO Home + +~~~~~~~~~~~~~~~~~~ + 3.4.1 (2017-08-02) ~~~~~~~~~~~~~~~~~~ From bda4b5d264c14c6d8b1f0d71a16257fa71c50934 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 16 Aug 2017 15:33:36 +0300 Subject: [PATCH 021/211] Docs: Create Advanced Scripting section for `platformio.ini` --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index c3dc1fa9..ca6e13c5 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit c3dc1fa9bfe03c7f928ffae4ba45b7ebd5dacbe9 +Subproject commit ca6e13c5f73e24e22c79f9080f137465d1d210b6 From 04c381d4406614f4690eb2d441883f310fd5669f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 17 Aug 2017 15:33:24 +0300 Subject: [PATCH 022/211] Sync docs and examples --- docs | 2 +- examples | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs b/docs index ca6e13c5..61ee28c9 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit ca6e13c5f73e24e22c79f9080f137465d1d210b6 +Subproject commit 61ee28c9952aef59330687283dc806aac9dbc8db diff --git a/examples b/examples index 59660b1f..de48488c 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 59660b1fe778bce4114f08b3be723174ebfecc6f +Subproject commit de48488cd2497fc2069090f35bc154ec557d51e9 From 743de4248439c56674bcb40efe111bfa4df1a601 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 17 Aug 2017 17:18:23 +0300 Subject: [PATCH 023/211] Add "test_ignore" to known options list --- platformio/commands/run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/commands/run.py b/platformio/commands/run.py index fd7a29a0..64d27c23 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -132,8 +132,8 @@ class EnvironmentProcessor(object): "upload_protocol", "upload_speed", "upload_flags", "upload_resetmethod", "lib_deps", "lib_ignore", "lib_extra_dirs", "lib_ldf_mode", "lib_compat_mode", - "lib_archive", "piotest", "test_transport", "test_ignore", - "test_port", "debug_tool", "debug_port", + "lib_archive", "piotest", "test_transport", "test_filter", + "test_ignore", "test_port", "debug_tool", "debug_port", "debug_init_cmds", "debug_extra_cmds", "debug_server", "debug_init_break", "debug_load_cmd", "monitor_port", "monitor_baud", "monitor_rts", "monitor_dtr") From 4ff1d640b393c9f6e43871a5b214880e66756161 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 17 Aug 2017 23:55:42 +0300 Subject: [PATCH 024/211] Minor fixes --- HISTORY.rst | 2 +- platformio/builder/tools/piolib.py | 2 +- platformio/util.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index d076ce7a..5b46cafc 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -5,10 +5,10 @@ PlatformIO 3.0 -------------- 3.5.0 (2017-??-??) +~~~~~~~~~~~~~~~~~~ * PIO Home -~~~~~~~~~~~~~~~~~~ 3.4.1 (2017-08-02) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index ddc8229e..391b5084 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -712,7 +712,7 @@ def BuildProjectLibraries(env): print "Library Dependency Graph" print_deps_tree(project) else: - print "Project does not have dependencies" + print "No dependencies" return project.build() diff --git a/platformio/util.py b/platformio/util.py index 07b2b33d..03f6f134 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -152,8 +152,8 @@ class memoized(object): class throttle(object): - def __init__(self, limit): - self.limit = limit # milliseconds + def __init__(self, threshhold): + self.threshhold = threshhold # milliseconds self.last = 0 def __call__(self, fn): @@ -161,8 +161,8 @@ class throttle(object): @wraps(fn) def wrapper(*args, **kwargs): diff = int(round((time() - self.last) * 1000)) - if diff < self.limit: - sleep((self.limit - diff) * 0.001) + if diff < self.threshhold: + sleep((self.threshhold - diff) * 0.001) self.last = time() return fn(*args, **kwargs) From 44909f9ce805fde510709b4168c70981da8e55e2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 18 Aug 2017 01:23:15 +0300 Subject: [PATCH 025/211] Switch to "develop" version of PIO Core Installer while it isn't merged to "master" // Resolve #1017 --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 61ee28c9..61e1bc03 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 61ee28c9952aef59330687283dc806aac9dbc8db +Subproject commit 61e1bc03ec6051a04f80d85554e5294ac817c509 From e6faed5dd937f6a020d505d06a6052df532e4480 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 18 Aug 2017 01:26:31 +0300 Subject: [PATCH 026/211] Update history --- HISTORY.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 5b46cafc..9b12cc8d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,7 +8,8 @@ PlatformIO 3.0 ~~~~~~~~~~~~~~~~~~ * PIO Home - +* Fixed "Super-Quick (Mac / Linux)" installer script + (`issue #1017 `_) 3.4.1 (2017-08-02) ~~~~~~~~~~~~~~~~~~ From 845991f1d32383557fd08d567c1b88a9dceb1032 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 18 Aug 2017 22:41:11 +0300 Subject: [PATCH 027/211] J-Link as debugger and uploader --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 61e1bc03..781d9ce1 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 61e1bc03ec6051a04f80d85554e5294ac817c509 +Subproject commit 781d9ce1da428fb1b51e06936022f598d6802e95 From 22733ea110133ef28a05f0f554ac40b2b346d396 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 22 Aug 2017 19:52:12 +0300 Subject: [PATCH 028/211] Docs: Minor fix --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 781d9ce1..b5d4e5a2 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 781d9ce1da428fb1b51e06936022f598d6802e95 +Subproject commit b5d4e5a2cca2cfcf24c127052c014fb77c0c3e8f From 297c173418d3c188e8a1640b57413d46f1ecf9a9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 23 Aug 2017 17:05:11 +0300 Subject: [PATCH 029/211] Docs: Fix invalid hotkey for VSCode Tasks --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index b5d4e5a2..7f1a9217 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit b5d4e5a2cca2cfcf24c127052c014fb77c0c3e8f +Subproject commit 7f1a9217f18d13f749c9236285b738065a4b327b From 3ce71045420adfc7e64153d63eb6a4e7320a2608 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 23 Aug 2017 21:46:31 +0300 Subject: [PATCH 030/211] Fix broken links --- HISTORY.rst | 20 ++++++++++---------- docs | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 9b12cc8d..a97e898d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -111,7 +111,7 @@ PlatformIO 3.0 command (`issue #430 `_) * List supported frameworks, SDKs with a new - `pio platform frameworks `__ command + `pio platform frameworks `__ command * Visual Studio Code extension for PlatformIO (`issue #619 `_) * Added new options ``--no-reset``, ``--monitor-rts`` and ``--monitor-dtr`` @@ -229,7 +229,7 @@ PlatformIO 3.0 * `PlatformIO Plus `__ - + Local and Embedded `Unit Testing `__ + + Local and Embedded `Unit Testing `__ (`issue #408 `_, `issue #519 `_) @@ -900,7 +900,7 @@ PlatformIO 2.0 `windows_x86 `__ development platforms (`issue #263 `_) -* Added `PlatformIO Demo `_ +* Added `PlatformIO Demo `_ page to documentation * Simplified `installation `__ process of PlatformIO @@ -1259,7 +1259,7 @@ PlatformIO 1.0 (`issue #83 `_) * Added ``--json-output`` option to `platformio boards `__ - and `platformio search `__ + and `platformio search `__ commands which allows to return the output in `JSON `_ format (`issue #42 `_) * Allowed to ignore some libs from *Library Dependency Finder* via @@ -1300,7 +1300,7 @@ PlatformIO 0.0 ~~~~~~~~~~~~~~~~~~~ * Added ``--json-output`` option to - `platformio list `__, + `platformio list `__, `platformio serialports list `__ and `platformio lib list `__ commands which allows to return the output in `JSON `_ format @@ -1344,14 +1344,14 @@ PlatformIO 0.0 * Ask user to install platform (when it hasn't been installed yet) within `platformio run `__ - and `platformio show `_ commands + and `platformio show `_ commands * Improved main `documentation `_ * Fixed "*OSError: [Errno 2] No such file or directory*" within `platformio run `__ command when PlatformIO isn't installed properly -* Fixed example for `Eclipse IDE with Tiva board `_ +* Fixed example for Eclipse IDE with Tiva board (`issue #32 `_) -* Upgraded `Eclipse Project Examples `_ +* Upgraded Eclipse Project Examples to latest *Luna* and *PlatformIO* releases 0.9.0 (2014-12-01) @@ -1440,7 +1440,7 @@ PlatformIO 0.0 * Implemented (especially for `SmartAnthill `_) `platformio run -t uploadlazy `_ target (no dependencies to framework libs, ELF and etc.) -* Allowed to skip default packages via `platformio install --skip-default-package `_ +* Allowed to skip default packages via `platformio install --skip-default-package `_ option * Added tools for *Raspberry Pi* platform * Added support for *Microduino* and *Raspduino* boards in @@ -1449,7 +1449,7 @@ PlatformIO 0.0 0.3.1 (2014-06-21) ~~~~~~~~~~~~~~~~~~ -* Fixed auto-installer for Windows OS (bug with %PATH% customisations) +* Fixed auto-installer for Windows OS (bug with %PATH% custom installation) 0.3.0 (2014-06-21) diff --git a/docs b/docs index 7f1a9217..ff519145 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 7f1a9217f18d13f749c9236285b738065a4b327b +Subproject commit ff519145a2459e9e39e5d6848f4386977c0139e5 From b12c4d171e16021dcc1afad5fbfa183cf2540259 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 26 Aug 2017 16:51:27 +0300 Subject: [PATCH 031/211] Sync docs --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index ff519145..6193062d 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit ff519145a2459e9e39e5d6848f4386977c0139e5 +Subproject commit 6193062d560a7f9cba755e8a2d9a42a2f36047f4 From 2b7b852a68bb47112b5d395b9f5f0dbe591b8e33 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 29 Aug 2017 14:16:30 +0300 Subject: [PATCH 032/211] Update VSCode docs --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 6193062d..2f7ed651 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 6193062d560a7f9cba755e8a2d9a42a2f36047f4 +Subproject commit 2f7ed6515cc3355265511912b188312ae0f421a2 From 01a6ae656ffdfbb955181a62203e1ac5f155e94e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 31 Aug 2017 18:32:52 +0300 Subject: [PATCH 033/211] Depend on new PIO Home 0.2.0 --- platformio/managers/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index 66109093..1161e437 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -21,9 +21,9 @@ from platformio import __version__, exception, util from platformio.managers.package import PackageManager CORE_PACKAGES = { - "contrib-piohome": ">=0.1.2,<2", + "contrib-piohome": ">=0.2.0,<2", "pysite-pioplus": ">=0.4.2,<2", - "tool-pioplus": ">=0.10.2,<2", + "tool-pioplus": ">=0.10.5,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" } From a55ccb2b281ea85f9d52072b0aa7abc422cbe5a6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 31 Aug 2017 18:33:17 +0300 Subject: [PATCH 034/211] Docs: Add CI for GitLab --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 2f7ed651..d0d8dc7d 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 2f7ed6515cc3355265511912b188312ae0f421a2 +Subproject commit d0d8dc7dc337e6a9ef4d415ebb118e4b04f9f339 From 3fe9ea1b01e238b68a5bb7bfdd9439a0854cba73 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 31 Aug 2017 18:35:15 +0300 Subject: [PATCH 035/211] Bump version to 3.5.0a5 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index f6142d3c..d8e937f4 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a4") +VERSION = (3, 5, "0a5") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 49244072c4fcd9004e8d389c377d999161816287 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 31 Aug 2017 20:56:25 +0300 Subject: [PATCH 036/211] Improve fetching of logical disks --- platformio/util.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platformio/util.py b/platformio/util.py index 03f6f134..969a3a7c 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -458,14 +458,17 @@ def get_logicaldisks(): match = disknamere.match(line.strip()) if not match: continue - disks.append({"disk": match.group(1), "name": match.group(2)}) + disks.append({ + "disk": match.group(1) + "\\", + "name": match.group(2) + }) return disks except WindowsError: # pylint: disable=undefined-variable pass # try "fsutil" result = exec_command(["fsutil", "fsinfo", "drives"]).get("out", "") for disk in re.findall(r"[A-Z]:\\", result): - disks.append({"disk": disk[:-1], "name": disk}) + disks.append({"disk": disk, "name": None}) return disks else: result = exec_command(["df"]).get("out") From 04ec65df3e79e11eb58b42ff7a51132a31982033 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 31 Aug 2017 23:12:02 +0300 Subject: [PATCH 037/211] Minor fixes --- platformio/maintenance.py | 51 +++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/platformio/maintenance.py b/platformio/maintenance.py index db4ac275..db68423b 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -34,33 +34,10 @@ from platformio.managers.lib import LibraryManager from platformio.managers.platform import PlatformFactory, PlatformManager -def in_silence(ctx=None): - ctx = ctx or app.get_session_var("command_ctx") - assert ctx - ctx_args = ctx.args or [] - return ctx_args and any([ - ctx.args[0] == "upgrade", "--json-output" in ctx_args, - "--version" in ctx_args - ]) - - def on_platformio_start(ctx, force, caller): - if not caller: - if getenv("PLATFORMIO_CALLER"): - caller = getenv("PLATFORMIO_CALLER") - elif getenv("VSCODE_PID") or getenv("VSCODE_NLS_CONFIG"): - caller = "vscode" - elif util.is_container(): - if getenv("C9_UID"): - caller = "C9" - elif getenv("USER") == "cabox": - caller = "CA" - elif getenv("CHE_API", getenv("CHE_API_ENDPOINT")): - caller = "Che" - app.set_session_var("command_ctx", ctx) app.set_session_var("force_option", force) - app.set_session_var("caller_id", caller) + set_caller(caller) telemetry.on_command() if not in_silence(ctx): @@ -86,6 +63,32 @@ def on_platformio_exception(e): telemetry.on_exception(e) +def in_silence(ctx=None): + ctx = ctx or app.get_session_var("command_ctx") + assert ctx + ctx_args = ctx.args or [] + return ctx_args and any([ + ctx.args[0] == "upgrade", "--json-output" in ctx_args, + "--version" in ctx_args + ]) + + +def set_caller(caller=None): + if not caller: + if getenv("PLATFORMIO_CALLER"): + caller = getenv("PLATFORMIO_CALLER") + elif getenv("VSCODE_PID") or getenv("VSCODE_NLS_CONFIG"): + caller = "vscode" + elif util.is_container(): + if getenv("C9_UID"): + caller = "C9" + elif getenv("USER") == "cabox": + caller = "CA" + elif getenv("CHE_API", getenv("CHE_API_ENDPOINT")): + caller = "Che" + app.set_session_var("caller_id", caller) + + class Upgrader(object): def __init__(self, from_version, to_version): From 3b5c73b1a3064d46b4ab6d17272cbcf2e6850ac4 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 1 Sep 2017 00:39:17 +0300 Subject: [PATCH 038/211] Bump version to 3.5.0a6 --- docs | 2 +- platformio/__init__.py | 2 +- platformio/managers/core.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs b/docs index d0d8dc7d..6e561ca7 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit d0d8dc7dc337e6a9ef4d415ebb118e4b04f9f339 +Subproject commit 6e561ca7ba7e0fc90c5403147cd601cba5e3a1cd diff --git a/platformio/__init__.py b/platformio/__init__.py index d8e937f4..c6eea690 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a5") +VERSION = (3, 5, "0a6") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/managers/core.py b/platformio/managers/core.py index 1161e437..abf8891e 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -21,9 +21,9 @@ from platformio import __version__, exception, util from platformio.managers.package import PackageManager CORE_PACKAGES = { - "contrib-piohome": ">=0.2.0,<2", + "contrib-piohome": ">=0.2.1,<2", "pysite-pioplus": ">=0.4.2,<2", - "tool-pioplus": ">=0.10.5,<2", + "tool-pioplus": ">=0.10.6,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" } From 8f7483cddf9bcf967f4ce1401666dfd1f0af393c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 1 Sep 2017 14:31:11 +0300 Subject: [PATCH 039/211] Update VSCode docs --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 6e561ca7..87def634 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 6e561ca7ba7e0fc90c5403147cd601cba5e3a1cd +Subproject commit 87def6347e0e1a4a5499dfc02c71b3e361f1c510 From 3afac476e51b260ab452fc90d063477143ed6df5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 1 Sep 2017 20:27:24 +0300 Subject: [PATCH 040/211] Docs: Remove Crisp chat --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 87def634..dafaa45e 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 87def6347e0e1a4a5499dfc02c71b3e361f1c510 +Subproject commit dafaa45eb92a6d168f503a0c8a23c15994f6b6ac From ccd650dda0f87d63e8a22b705079d5b6ef35dd7c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 2 Sep 2017 14:43:08 +0300 Subject: [PATCH 041/211] Fix invalid params order when installing PIO Core without PIP Cache --- scripts/get-platformio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/get-platformio.py b/scripts/get-platformio.py index 357d47aa..6d3cbe1d 100644 --- a/scripts/get-platformio.py +++ b/scripts/get-platformio.py @@ -125,7 +125,7 @@ def install_platformio(): r = exec_python_cmd(cmd) assert r['returncode'] == 0 except AssertionError: - cmd.insert(1, "--no-cache-dir") + cmd.insert(2, "--no-cache-dir") r = exec_python_cmd(cmd) if r: print_exec_result(r) From 9b66abf5effd810b6957897692920c695883c839 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 2 Sep 2017 15:39:32 +0300 Subject: [PATCH 042/211] Fix issue with "IOError" in VSCode when processing a project --- HISTORY.rst | 1 + platformio/managers/platform.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index a97e898d..61024d98 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -10,6 +10,7 @@ PlatformIO 3.0 * PIO Home * Fixed "Super-Quick (Mac / Linux)" installer script (`issue #1017 `_) +* Fixed issue with "IOError" in VSCode when processing a project 3.4.1 (2017-08-02) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 6497b00f..3ee2b19f 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -15,6 +15,7 @@ import base64 import os import re +import sys from imp import load_source from multiprocessing import cpu_count from os.path import basename, dirname, isdir, isfile, join @@ -394,7 +395,10 @@ class PlatformRunMixin(object): fg = (None, "yellow", "red")[level - 1] if level == 1 and "is up to date" in line: fg = "green" - click.secho(line, fg=fg, err=level > 1) + try: + click.secho(line, fg=fg, err=level > 1) + except IOError: + (sys.stderr.write if level > 1 else sys.stdout.write)(line + "\n") @staticmethod def get_job_nums(): From 68c75735f4746dc0208ec6ffe143422748fc6267 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 2 Sep 2017 15:39:53 +0300 Subject: [PATCH 043/211] Bump version to 3.5.0a7 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index c6eea690..f1855ae4 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a6") +VERSION = (3, 5, "0a7") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From b55b80ecc89f4ed791df8784803d250cb7fe55d1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 2 Sep 2017 16:23:24 +0300 Subject: [PATCH 044/211] Better catching of IOError for VSCode/Colorama --- platformio/__main__.py | 12 ++++++++++++ platformio/managers/platform.py | 6 +----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/platformio/__main__.py b/platformio/__main__.py index b1872fd2..5c9b0da0 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -101,6 +101,18 @@ def main(): except: # pylint: disable=bare-except pass + # Handle IOError issue with colorama/VSCode + click_echo_origin = click.echo + + def _echo(*args, **kwargs): + try: + click_echo_origin(*args, **kwargs) + except IOError: + (sys.stderr.write if kwargs.get("err") else + sys.stdout.write)("%s\n" % (args[0] if args else "")) + + click.echo = _echo + cli(None, None, None) except Exception as e: # pylint: disable=W0703 if not isinstance(e, exception.ReturnErrorCode): diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 3ee2b19f..6497b00f 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -15,7 +15,6 @@ import base64 import os import re -import sys from imp import load_source from multiprocessing import cpu_count from os.path import basename, dirname, isdir, isfile, join @@ -395,10 +394,7 @@ class PlatformRunMixin(object): fg = (None, "yellow", "red")[level - 1] if level == 1 and "is up to date" in line: fg = "green" - try: - click.secho(line, fg=fg, err=level > 1) - except IOError: - (sys.stderr.write if level > 1 else sys.stdout.write)(line + "\n") + click.secho(line, fg=fg, err=level > 1) @staticmethod def get_job_nums(): From a127251107afe133dc50ff7e49f4337c7688413d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 2 Sep 2017 17:58:35 +0300 Subject: [PATCH 045/211] Catch click's IOError for VSCode Terminal --- platformio/__main__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/platformio/__main__.py b/platformio/__main__.py index 5c9b0da0..5db83611 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -101,17 +101,18 @@ def main(): except: # pylint: disable=bare-except pass - # Handle IOError issue with colorama/VSCode - click_echo_origin = click.echo + # Handle IOError issue with VSCode's Terminal (Windows) + click_echo_origin = [click.echo, click.secho] - def _echo(*args, **kwargs): + def _safe_echo(origin, *args, **kwargs): try: - click_echo_origin(*args, **kwargs) + click_echo_origin[origin](*args, **kwargs) except IOError: (sys.stderr.write if kwargs.get("err") else sys.stdout.write)("%s\n" % (args[0] if args else "")) - click.echo = _echo + click.echo = lambda *args, **kwargs: _safe_echo(0, *args, **kwargs) + click.secho = lambda *args, **kwargs: _safe_echo(1, *args, **kwargs) cli(None, None, None) except Exception as e: # pylint: disable=W0703 From 34ed4678d76f22d6bcfa7fe09b121348ddf8d818 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 2 Sep 2017 18:02:24 +0300 Subject: [PATCH 046/211] Moved configuration code to a separate function, re-use it for PIO Core+ --- platformio/__main__.py | 55 ++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/platformio/__main__.py b/platformio/__main__.py index 5db83611..d4da091c 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -80,40 +80,43 @@ def process_result(ctx, result, force, caller): # pylint: disable=W0613 maintenance.on_platformio_end(ctx, result) -def main(): - try: - if "cygwin" in system().lower(): - raise exception.CygwinEnvDetected() +def configure(): + if "cygwin" in system().lower(): + raise exception.CygwinEnvDetected() - # https://urllib3.readthedocs.org - # /en/latest/security.html#insecureplatformwarning + # https://urllib3.readthedocs.org + # /en/latest/security.html#insecureplatformwarning + try: + import urllib3 + urllib3.disable_warnings() + except (AttributeError, ImportError): + pass + + # handle PLATFORMIO_FORCE_COLOR + if str(os.getenv("PLATFORMIO_FORCE_COLOR", "")).lower() == "true": try: - import urllib3 - urllib3.disable_warnings() - except (AttributeError, ImportError): + # pylint: disable=protected-access + click._compat.isatty = lambda stream: True + except: # pylint: disable=bare-except pass - # handle PLATFORMIO_FORCE_COLOR - if str(os.getenv("PLATFORMIO_FORCE_COLOR", "")).lower() == "true": - try: - # pylint: disable=protected-access - click._compat.isatty = lambda stream: True - except: # pylint: disable=bare-except - pass + # Handle IOError issue with VSCode's Terminal (Windows) + click_echo_origin = [click.echo, click.secho] - # Handle IOError issue with VSCode's Terminal (Windows) - click_echo_origin = [click.echo, click.secho] + def _safe_echo(origin, *args, **kwargs): + try: + click_echo_origin[origin](*args, **kwargs) + except IOError: + (sys.stderr.write if kwargs.get("err") else + sys.stdout.write)("%s\n" % (args[0] if args else "")) - def _safe_echo(origin, *args, **kwargs): - try: - click_echo_origin[origin](*args, **kwargs) - except IOError: - (sys.stderr.write if kwargs.get("err") else - sys.stdout.write)("%s\n" % (args[0] if args else "")) + click.echo = lambda *args, **kwargs: _safe_echo(0, *args, **kwargs) + click.secho = lambda *args, **kwargs: _safe_echo(1, *args, **kwargs) - click.echo = lambda *args, **kwargs: _safe_echo(0, *args, **kwargs) - click.secho = lambda *args, **kwargs: _safe_echo(1, *args, **kwargs) +def main(): + try: + configure() cli(None, None, None) except Exception as e: # pylint: disable=W0703 if not isinstance(e, exception.ReturnErrorCode): From ed6b1964596f6e771e48686b3c52161df048ccba Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 2 Sep 2017 18:33:56 +0300 Subject: [PATCH 047/211] Bump version to 3.5.0a8 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index f1855ae4..70be693d 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a7") +VERSION = (3, 5, "0a8") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 95aaca5e026c81e3f5cfdc69aeb446011eaca356 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 3 Sep 2017 20:58:48 +0300 Subject: [PATCH 048/211] Do not skip fixed packages with custom requirements --- platformio/managers/package.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 54fcaa61..fd8b0393 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -556,8 +556,8 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): assert isdir(pkg_dir) latest = None manifest = self.load_manifest(pkg_dir) - # skip a fixed package to a specific version - if "@" in pkg_dir and "__src_url" not in manifest: + # skip fixed package to a specific version + if "@" in pkg_dir and "__src_url" not in manifest and not requirements: return None if "__src_url" in manifest: @@ -721,7 +721,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): elif latest is False: click.echo("[%s]" % (click.style("Up-to-date", fg="green"))) else: - click.echo("[%s]" % (click.style("Skip", fg="yellow"))) + click.echo("[%s]" % (click.style("Fixed", fg="yellow"))) if only_check or not latest: return From 113746dc749508817bffddf6958727ff8608f508 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 3 Sep 2017 22:40:00 +0300 Subject: [PATCH 049/211] Introduce "get_all_boards" API to PlatformManager --- platformio/commands/boards.py | 22 +++------------------- platformio/managers/platform.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/platformio/commands/boards.py b/platformio/commands/boards.py index 0d9d6015..7e7836d6 100644 --- a/platformio/commands/boards.py +++ b/platformio/commands/boards.py @@ -16,7 +16,6 @@ import json import click -from platformio.exception import APIRequestError, InternetIsOffline from platformio.managers.platform import PlatformManager @@ -80,27 +79,12 @@ def print_boards(boards): def _get_boards(installed=False): - boards = PlatformManager().get_installed_boards() - if not installed: - know_boards = ["%s:%s" % (b['platform'], b['id']) for b in boards] - try: - for board in PlatformManager().get_registered_boards(): - key = "%s:%s" % (board['platform'], board['id']) - if key not in know_boards: - boards.append(board) - except InternetIsOffline: - pass - return sorted(boards, key=lambda b: b['name']) - + pm = PlatformManager() + return pm.get_installed_boards() if installed else pm.get_all_boards() def _print_boards_json(query, installed=False): result = [] - try: - boards = _get_boards(installed) - except APIRequestError: - if not installed: - boards = _get_boards(True) - for board in boards: + for board in _get_boards(installed): if query: search_data = "%s %s" % (board['id'], json.dumps(board).lower()) if query.lower() not in search_data.lower(): diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 6497b00f..f3075230 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -167,6 +167,18 @@ class PlatformManager(BasePkgManager): def get_registered_boards(): return util.get_api_result("/boards", cache_valid="30d") + def get_all_boards(self): + boards = self.get_installed_boards() + know_boards = ["%s:%s" % (b['platform'], b['id']) for b in boards] + try: + for board in self.get_registered_boards(): + key = "%s:%s" % (board['platform'], board['id']) + if key not in know_boards: + boards.append(board) + except (exception.APIRequestError, exception.InternetIsOffline): + pass + return sorted(boards, key=lambda b: b['name']) + def board_config(self, id_, platform=None): for manifest in self.get_installed_boards(): if manifest['id'] == id_ and (not platform From 7301b9e808679b0c8847ab51f11926d1c0ffdc60 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 5 Sep 2017 14:13:00 +0300 Subject: [PATCH 050/211] Prepend Python's binary folder before calling PIO Core+ --- platformio/managers/core.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index abf8891e..127215ba 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -15,7 +15,7 @@ import os import subprocess import sys -from os.path import join +from os.path import dirname, join from platformio import __version__, exception, util from platformio.managers.package import PackageManager @@ -100,7 +100,10 @@ def pioplus_call(args, **kwargs): sys.version.split()[0])) 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") util.copy_pythonpath_to_osenv() code = subprocess.call([pioplus_path] + args, **kwargs) From f4c6919800e8bcb0ff36df2589220473ba9dee25 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 5 Sep 2017 14:23:49 +0300 Subject: [PATCH 051/211] Don't verify SSL certificates for Python < 2.7.9 --- platformio/downloader.py | 7 ++++++- platformio/util.py | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/platformio/downloader.py b/platformio/downloader.py index 986d3283..9a3b85d9 100644 --- a/platformio/downloader.py +++ b/platformio/downloader.py @@ -15,6 +15,7 @@ from email.utils import parsedate_tz from math import ceil from os.path import getsize, join +from sys import version_info from time import mktime import click @@ -30,9 +31,13 @@ class FileDownloader(object): CHUNK_SIZE = 1024 def __init__(self, url, dest_dir=None): + self._request = None # make connection 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: raise FDUnrecognizedStatusCode(self._request.status_code, url) diff --git a/platformio/util.py b/platformio/util.py index 969a3a7c..0a056462 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -504,7 +504,7 @@ def _get_api_result( result = None r = None - disable_ssl_check = sys.version_info < (2, 7, 9) + verify_ssl = sys.version_info >= (2, 7, 9) headers = get_request_defheaders() if not url.startswith("http"): @@ -520,14 +520,14 @@ def _get_api_result( data=data, headers=headers, auth=auth, - verify=not disable_ssl_check) + verify=verify_ssl) else: r = _api_request_session().get( url, params=params, headers=headers, auth=auth, - verify=not disable_ssl_check) + verify=verify_ssl) result = r.json() r.raise_for_status() except requests.exceptions.HTTPError as e: From 274c1a40a598a336021ab914f729297bad70b098 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 5 Sep 2017 14:42:56 +0300 Subject: [PATCH 052/211] Bump version to 3.5.0a9 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 70be693d..cf0ed85b 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a8") +VERSION = (3, 5, "0a9") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From a0cae2b1a6687cd5424b1faa53370c07a6558df3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 5 Sep 2017 19:40:11 +0300 Subject: [PATCH 053/211] Update docs for PIO IDE for Atom --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index dafaa45e..992c6145 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit dafaa45eb92a6d168f503a0c8a23c15994f6b6ac +Subproject commit 992c6145f794b87594f244abab8cfd21ea25dd8c From a934efa90aaf33020fbbf7e7bfe42537dfa3558c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 6 Sep 2017 02:04:06 +0300 Subject: [PATCH 054/211] Sync docs --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 992c6145..cdfe3014 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 992c6145f794b87594f244abab8cfd21ea25dd8c +Subproject commit cdfe301454c318ce79a157d7bb4f8bf5c140ab26 From f24e97e933701113414eb320deebf1957f6e25c3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 6 Sep 2017 14:37:04 +0300 Subject: [PATCH 055/211] Skip missing package when checking for updates --- platformio/managers/package.py | 3 ++- tests/commands/test_lib.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index fd8b0393..d66cb1f9 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -553,7 +553,8 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): `False` - package is up-to-date `String` - a found latest version """ - assert isdir(pkg_dir) + if not isdir(pkg_dir): + return None latest = None manifest = self.load_manifest(pkg_dir) # skip fixed package to a specific version diff --git a/tests/commands/test_lib.py b/tests/commands/test_lib.py index 31ed9809..02eac43b 100644 --- a/tests/commands/test_lib.py +++ b/tests/commands/test_lib.py @@ -184,7 +184,7 @@ def test_global_lib_update(clirunner, validate_cliresult, isolated_pio_home): result = clirunner.invoke(cmd_lib, ["-g", "update"]) validate_cliresult(result) validate_cliresult(result) - assert result.output.count("[Skip]") == 5 + assert result.output.count("[Fixed]") == 5 assert result.output.count("[Up-to-date]") == 10 assert "Uninstalling ArduinoJson @ 5.7.3" in result.output assert "Uninstalling IRremoteESP8266 @ fee16e880b" in result.output From fd98aa0ff8e821ce7735d3747a2cfdd2392c72f1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 6 Sep 2017 20:57:56 +0300 Subject: [PATCH 056/211] Fix PyLint warning --- docs | 2 +- platformio/commands/boards.py | 1 + platformio/managers/package.py | 8 ++------ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/docs b/docs index cdfe3014..e676def2 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit cdfe301454c318ce79a157d7bb4f8bf5c140ab26 +Subproject commit e676def2230a7a40fdf6865530798e279e906f96 diff --git a/platformio/commands/boards.py b/platformio/commands/boards.py index 7e7836d6..522a8a47 100644 --- a/platformio/commands/boards.py +++ b/platformio/commands/boards.py @@ -82,6 +82,7 @@ def _get_boards(installed=False): pm = PlatformManager() return pm.get_installed_boards() if installed else pm.get_all_boards() + def _print_boards_json(query, installed=False): result = [] for board in _get_boards(installed): diff --git a/platformio/managers/package.py b/platformio/managers/package.py index d66cb1f9..7d1f9216 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -30,7 +30,7 @@ from platformio.downloader import FileDownloader from platformio.unpacker import FileUnpacker from platformio.vcsclient import VCSClientFactory -# pylint: disable=too-many-arguments +# pylint: disable=too-many-arguments, too-many-return-statements class PackageRepoIterator(object): @@ -690,11 +690,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): label=manifest['name']) return True - def update( # pylint: disable=too-many-return-statements - self, - package, - requirements=None, - only_check=False): + def update(self, package, requirements=None, only_check=False): if isdir(package): pkg_dir = package else: From e176e9922ac959e5e984f9517157c17a78f48fd8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 7 Sep 2017 20:30:48 +0300 Subject: [PATCH 057/211] Sync docs --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index e676def2..4cea9b9f 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit e676def2230a7a40fdf6865530798e279e906f96 +Subproject commit 4cea9b9fdcd295c98c54c536c29d92fa4a4f86e7 From 674aa5c4d85344f61b9851b28c9b2abc8b8742f9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 9 Sep 2017 20:57:25 +0300 Subject: [PATCH 058/211] Decrease API cache timeouts --- platformio/commands/lib.py | 4 ++-- platformio/commands/platform.py | 4 ++-- platformio/managers/lib.py | 4 ++-- platformio/managers/platform.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index f801e23a..997e39ed 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -204,7 +204,7 @@ def lib_search(query, json_output, page, noninteractive, **filters): result = get_api_result( "/v2/lib/search", dict(query=" ".join(query), page=page), - cache_valid="3d") + cache_valid="1d") if json_output: click.echo(json.dumps(result)) @@ -252,7 +252,7 @@ def lib_search(query, json_output, page, noninteractive, **filters): "/v2/lib/search", {"query": " ".join(query), "page": int(result['page']) + 1}, - cache_valid="3d") + cache_valid="1d") @cli.command("list", short_help="List installed libraries") diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index 9699a4d7..f67cccfc 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -47,7 +47,7 @@ def _print_platforms(platforms): def _get_registry_platforms(): - platforms = util.get_api_result("/platforms", cache_valid="30d") + platforms = util.get_api_result("/platforms", cache_valid="7d") pm = PlatformManager() for platform in platforms or []: platform['versions'] = pm.get_all_repo_versions(platform['name']) @@ -188,7 +188,7 @@ def platform_search(query, json_output): @click.option("--json-output", is_flag=True) def platform_frameworks(query, json_output): frameworks = [] - for framework in util.get_api_result("/frameworks", cache_valid="30d"): + for framework in util.get_api_result("/frameworks", cache_valid="7d"): if query == "all": query = "" search_data = json.dumps(framework) diff --git a/platformio/managers/lib.py b/platformio/managers/lib.py index 5ce9fe99..75abbadb 100644 --- a/platformio/managers/lib.py +++ b/platformio/managers/lib.py @@ -193,7 +193,7 @@ class LibraryManager(BasePkgManager): util.get_api_result( "/lib/info/%d" % self.get_pkg_id_by_name( name, requirements, silent=silent), - cache_valid="1d")['versions'], requirements) + cache_valid="1h")['versions'], requirements) return item['name'] if item else None def get_pkg_id_by_name(self, @@ -315,7 +315,7 @@ class LibraryManager(BasePkgManager): lib_info = None result = util.get_api_result( - "/v2/lib/search", dict(query=" ".join(query)), cache_valid="3d") + "/v2/lib/search", dict(query=" ".join(query)), cache_valid="1h") if result['total'] == 1: lib_info = result['items'][0] elif result['total'] > 1: diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index f3075230..de009bf2 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -165,7 +165,7 @@ class PlatformManager(BasePkgManager): @staticmethod @util.memoized def get_registered_boards(): - return util.get_api_result("/boards", cache_valid="30d") + return util.get_api_result("/boards", cache_valid="7d") def get_all_boards(self): boards = self.get_installed_boards() From b4159f9144d22d88ddfaa60c272786b7a59f440f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 9 Sep 2017 23:03:15 +0300 Subject: [PATCH 059/211] Docs: Update instruction how to install Espressif staging version --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 4cea9b9f..ff0edca6 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 4cea9b9fdcd295c98c54c536c29d92fa4a4f86e7 +Subproject commit ff0edca6999974b71da16e8d697ebf4865b299bf From 7963ce2cddd0c69f10eecaeb2347ade1e0ea811d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Sep 2017 17:38:42 +0300 Subject: [PATCH 060/211] Do not warn about "custom_" options in configuration file --- platformio/commands/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 64d27c23..e27aa455 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -227,7 +227,7 @@ class EnvironmentProcessor(object): v = self.RENAMED_PLATFORMS[v] # warn about unknown options - if k not in self.KNOWN_OPTIONS: + if k not in self.KNOWN_OPTIONS and not k.startswith("custom_"): click.secho( "Detected non-PlatformIO `%s` option in `[env:%s]` section" % (k, self.name), From 33242a02ce9cf15d7f0fbce7963ba7967ef7b250 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Sep 2017 17:39:41 +0300 Subject: [PATCH 061/211] Bump version to 3.5.0a10 --- docs | 2 +- platformio/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs b/docs index ff0edca6..cfd1df93 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit ff0edca6999974b71da16e8d697ebf4865b299bf +Subproject commit cfd1df9393c51956df64142f7035fafd7e0d3fce diff --git a/platformio/__init__.py b/platformio/__init__.py index cf0ed85b..9ab732f7 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a9") +VERSION = (3, 5, "0a10") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 998f4ed6e640c16b1d8f4d25653edcbe991ee534 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Sep 2017 00:57:36 +0300 Subject: [PATCH 062/211] Use VCS directly with "platform" option in configuration file --- docs | 2 +- platformio/managers/platform.py | 11 ++++++----- tests/test_managers.py | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs b/docs index cfd1df93..2a191b0b 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit cfd1df9393c51956df64142f7035fafd7e0d3fce +Subproject commit 2a191b0bd7625616fb32bd2219fc649b4cb63f80 diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index de009bf2..839e8a2b 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -210,18 +210,19 @@ class PlatformFactory(object): @classmethod def newPlatform(cls, name, requirements=None): + pm = PlatformManager() platform_dir = None if isdir(name): platform_dir = name - name = PlatformManager().load_manifest(platform_dir)['name'] + name = pm.load_manifest(platform_dir)['name'] elif name.endswith("platform.json") and isfile(name): platform_dir = dirname(name) name = util.load_json(name)['name'] else: - if not requirements and "@" in name: - name, requirements = name.rsplit("@", 1) - platform_dir = PlatformManager().get_package_dir( - name, requirements) + name, requirements, url = pm.parse_pkg_input(name, requirements) + platform_dir = pm.get_package_dir(name, requirements, url) + if platform_dir: + name = pm.load_manifest(platform_dir)['name'] if not platform_dir: raise exception.UnknownPlatform(name if not requirements else diff --git a/tests/test_managers.py b/tests/test_managers.py index 1f58e03e..a26742bc 100644 --- a/tests/test_managers.py +++ b/tests/test_managers.py @@ -25,8 +25,8 @@ def test_pkg_input_parser(): [("PkgName", "!=1.2.3,<2.0"), ("PkgName", "!=1.2.3,<2.0", None)], ["PkgName@1.2.3", ("PkgName", "1.2.3", None)], [("PkgName@1.2.3", "1.2.5"), ("PkgName@1.2.3", "1.2.5", None)], - ["id:13", ("id:13", None, None)], - ["id:13@~1.2.3", ("id:13", "~1.2.3", None)], + ["id=13", ("id=13", None, None)], + ["id=13@~1.2.3", ("id=13", "~1.2.3", None)], [ util.get_home_dir(), (".platformio", None, "file://" + util.get_home_dir()) From aa1c7609d21aabda6a93387752668d03af3a02f0 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Sep 2017 01:00:29 +0300 Subject: [PATCH 063/211] Bump version to 3.5.0a11 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 9ab732f7..2f56ee50 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a10") +VERSION = (3, 5, "0a11") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From fc7f1c0728954a6d13b048ccdca3da756584474d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Sep 2017 16:35:35 +0300 Subject: [PATCH 064/211] Fix platforms, packages, and libraries updating behind proxy // Resolve #1061 --- HISTORY.rst | 2 ++ platformio/util.py | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 61024d98..0bc3ed80 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -11,6 +11,8 @@ PlatformIO 3.0 * Fixed "Super-Quick (Mac / Linux)" installer script (`issue #1017 `_) * Fixed issue with "IOError" in VSCode when processing a project +* Fixed platforms, packages, and libraries updating behind proxy + (`issue #1061 `_) 3.4.1 (2017-08-02) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/util.py b/platformio/util.py index 0a056462..e9dc86c5 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -18,7 +18,6 @@ import json import os import platform import re -import socket import stat import subprocess import sys @@ -582,12 +581,10 @@ def get_api_result(url, params=None, data=None, auth=None, cache_valid=None): "Please try later.") -def internet_on(timeout=3): - socket.setdefaulttimeout(timeout) - for host in ("dl.bintray.com", "dl.platformio.org"): +def internet_on(): + for url in ("http://dl.bintray.com", "http://dl.platformio.org"): try: - socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, - 80)) + requests.get(url, timeout=3) return True except: # pylint: disable=bare-except pass From c9e1ae25480e5855c3e53ae178cb1976a31ab3ac Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Sep 2017 16:36:09 +0300 Subject: [PATCH 065/211] Bump version to 3.5.0a12 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 2f56ee50..a23df40e 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a11") +VERSION = (3, 5, "0a12") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 16c242e7fa882f40c57d5fe653093a7113973a9e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 17 Sep 2017 01:33:04 +0300 Subject: [PATCH 066/211] Better parsing of F_CPU --- platformio/managers/platform.py | 37 ++++++++++++++++++++++----------- tox.ini | 2 +- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 839e8a2b..05880c74 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -651,19 +651,32 @@ class PlatformBoardConfig(object): def get_brief_data(self): return { - "id": self.id, - "name": self._manifest['name'], - "platform": self._manifest.get("platform"), - "mcu": self._manifest.get("build", {}).get("mcu", "").upper(), + "id": + self.id, + "name": + self._manifest['name'], + "platform": + self._manifest.get("platform"), + "mcu": + self._manifest.get("build", {}).get("mcu", "").upper(), "fcpu": - int(self._manifest.get("build", {}).get("f_cpu", "0L")[:-1]), - "ram": self._manifest.get("upload", {}).get("maximum_ram_size", 0), - "rom": self._manifest.get("upload", {}).get("maximum_size", 0), - "connectivity": self._manifest.get("connectivity"), - "frameworks": self._manifest.get("frameworks"), - "debug": self.get_debug_data(), - "vendor": self._manifest['vendor'], - "url": self._manifest['url'] + int( + re.sub(r"[^\d]+", "", + self._manifest.get("build", {}).get("f_cpu", ""))), + "ram": + self._manifest.get("upload", {}).get("maximum_ram_size", 0), + "rom": + self._manifest.get("upload", {}).get("maximum_size", 0), + "connectivity": + self._manifest.get("connectivity"), + "frameworks": + self._manifest.get("frameworks"), + "debug": + self.get_debug_data(), + "vendor": + self._manifest['vendor'], + "url": + self._manifest['url'] } def get_debug_data(self): diff --git a/tox.ini b/tox.ini index d0974980..1232e76c 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,7 @@ usedevelop = True deps = isort flake8 - yapf<0.17 + yapf<0.18 pylint pytest commands = python --version From 68c56e042c502232967af7eb3fe322d79244ed79 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 17 Sep 2017 01:33:29 +0300 Subject: [PATCH 067/211] Bump version to 3.5.0a13 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index a23df40e..ba1f37a5 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a12") +VERSION = (3, 5, "0a13") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 22fb89e56ad4f35aa9af0226f0603f29dad93e4e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 17 Sep 2017 02:18:35 +0300 Subject: [PATCH 068/211] Fix tests --- platformio/managers/platform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 05880c74..dcaf7162 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -662,7 +662,7 @@ class PlatformBoardConfig(object): "fcpu": int( re.sub(r"[^\d]+", "", - self._manifest.get("build", {}).get("f_cpu", ""))), + self._manifest.get("build", {}).get("f_cpu", "0L"))), "ram": self._manifest.get("upload", {}).get("maximum_ram_size", 0), "rom": From 377008ee08520ec6dcc98b1ddceec461bfc01873 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 17 Sep 2017 02:21:59 +0300 Subject: [PATCH 069/211] New Microchip PIC32 boards --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 2a191b0b..fe62c1c7 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 2a191b0bd7625616fb32bd2219fc649b4cb63f80 +Subproject commit fe62c1c7dab124b2709ef023c0dbc7b81ac1e401 From 77fe1e818449fc4aa129247e9cb8472a2828efb3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 18 Sep 2017 14:06:16 +0300 Subject: [PATCH 070/211] Use -ggdb3 instead of -ggdb by default --- platformio/builder/tools/piomisc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index fc08ed93..98c28590 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -271,7 +271,7 @@ def PioClean(env, clean_dir): def ProcessDebug(env): if not env.subst("$PIODEBUGFLAGS"): - env.Replace(PIODEBUGFLAGS=["-Og", "-g3", "-ggdb"]) + env.Replace(PIODEBUGFLAGS=["-Og", "-g3", "-ggdb3"]) env.Append( BUILD_FLAGS=env.get("PIODEBUGFLAGS", []), BUILD_UNFLAGS=["-Os", "-O0", "-O1", "-O2", "-O3"]) From c677f24d8e1eb2860da66f91c1407d84a22495e6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 20 Sep 2017 18:49:19 +0300 Subject: [PATCH 071/211] Sync docs --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index fe62c1c7..06439a0d 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit fe62c1c7dab124b2709ef023c0dbc7b81ac1e401 +Subproject commit 06439a0d5a19ff52b1a4c79f00056056a02dd4f2 From 25da978fee0a0c9359f3f5c52818b126ecfe6fec Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 21 Sep 2017 15:07:38 +0300 Subject: [PATCH 072/211] Add support for "author" field in library.json manifest // Resolve #1055 --- platformio/managers/lib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platformio/managers/lib.py b/platformio/managers/lib.py index 75abbadb..ad3197a4 100644 --- a/platformio/managers/lib.py +++ b/platformio/managers/lib.py @@ -71,7 +71,10 @@ class LibraryManager(BasePkgManager): del manifest['sentence'] if "author" in manifest: - manifest['authors'] = [{"name": manifest['author']}] + if isinstance(manifest['author'], dict): + manifest['authors'] = [manifest['author']] + else: + manifest['authors'] = [{"name": manifest['author']}] del manifest['author'] if "authors" in manifest and not isinstance(manifest['authors'], list): From 2e2b1fda9cc4554ea7dc199bd0996ad7a4b6beab Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 21 Sep 2017 21:58:37 +0300 Subject: [PATCH 073/211] Bump version to 3.5.0a14 --- platformio/__init__.py | 2 +- platformio/managers/core.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index ba1f37a5..b558209c 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a13") +VERSION = (3, 5, "0a14") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/managers/core.py b/platformio/managers/core.py index 127215ba..a5ddce22 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -21,9 +21,9 @@ from platformio import __version__, exception, util from platformio.managers.package import PackageManager CORE_PACKAGES = { - "contrib-piohome": ">=0.2.1,<2", + "contrib-piohome": ">=0.3.0,<2", "pysite-pioplus": ">=0.4.2,<2", - "tool-pioplus": ">=0.10.6,<2", + "tool-pioplus": ">=0.10.10,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" } From 7c9989d9992448460d17f0acf10354bdaf1f087e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 21 Sep 2017 23:57:55 +0300 Subject: [PATCH 074/211] Fix tests for "platform" command --- tests/commands/test_platform.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/commands/test_platform.py b/tests/commands/test_platform.py index bdc50916..f6b1771a 100644 --- a/tests/commands/test_platform.py +++ b/tests/commands/test_platform.py @@ -54,11 +54,11 @@ def test_install_unknown_from_registry(clirunner, validate_cliresult, def test_install_known_version(clirunner, validate_cliresult, isolated_pio_home): result = clirunner.invoke(cli_platform.platform_install, [ - "atmelavr@1.1.0", "--skip-default-package", "--with-package", + "atmelavr@1.2.0", "--skip-default-package", "--with-package", "tool-avrdude" ]) validate_cliresult(result) - assert "atmelavr @ 1.1.0" in result.output + assert "atmelavr @ 1.2.0" in result.output assert "Installing tool-avrdude @" in result.output assert len(isolated_pio_home.join("packages").listdir()) == 1 @@ -102,7 +102,7 @@ def test_update_check(clirunner, validate_cliresult, isolated_pio_home): def test_update_raw(clirunner, validate_cliresult, isolated_pio_home): result = clirunner.invoke(cli_platform.platform_update) validate_cliresult(result) - assert "Uninstalling atmelavr @ 1.1.0:" in result.output + assert "Uninstalling atmelavr @ 1.2.0:" in result.output assert "PlatformManager: Installing atmelavr @" in result.output assert len(isolated_pio_home.join("packages").listdir()) == 1 From 71afea8d8040994ce2c79fc1ef6a1c5f1d01ff68 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 22 Sep 2017 01:22:21 +0300 Subject: [PATCH 075/211] Expand user folder for `lib_extra_dirs` --- platformio/builder/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platformio/builder/main.py b/platformio/builder/main.py index f811c13a..094c279f 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -16,7 +16,7 @@ import base64 import json import sys from os import environ -from os.path import join +from os.path import expanduser, join from time import time from SCons.Script import (ARGUMENTS, COMMAND_LINE_TARGETS, DEFAULT_TARGETS, @@ -141,6 +141,9 @@ if util.get_project_optional_dir("lib_extra_dirs"): env.Prepend(LIBSOURCE_DIRS=util.parse_conf_multi_values( util.get_project_optional_dir("lib_extra_dirs"))) env.Prepend(LIBSOURCE_DIRS=env.get("LIB_EXTRA_DIRS", [])) +env['LIBSOURCE_DIRS'] = [ + expanduser(d) if d.startswith("~") else d for d in env['LIBSOURCE_DIRS'] +] env.LoadPioPlatform(commonvars) From 837b040761d3804f974700dbaaeb7fa6a915d39c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 22 Sep 2017 01:22:41 +0300 Subject: [PATCH 076/211] Bump version to 3.5.0a15 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index b558209c..3e961553 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a14") +VERSION = (3, 5, "0a15") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From d9ae36728171f3c8bcb18a5c1a313c97516ab197 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 24 Sep 2017 00:33:12 +0300 Subject: [PATCH 077/211] Improve archive unpacker --- platformio/managers/package.py | 4 ++-- platformio/unpacker.py | 35 ++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 7d1f9216..47e63539 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -187,8 +187,8 @@ class PkgInstallerMixin(object): @staticmethod def unpack(source_path, dest_dir): - fu = FileUnpacker(source_path, dest_dir) - return fu.start() + with FileUnpacker(source_path) as fu: + return fu.unpack(dest_dir) @staticmethod def get_install_dirname(manifest): diff --git a/platformio/unpacker.py b/platformio/unpacker.py index 036dcc4c..4e789d1c 100644 --- a/platformio/unpacker.py +++ b/platformio/unpacker.py @@ -13,7 +13,7 @@ # limitations under the License. from os import chmod -from os.path import join, splitext +from os.path import join from tarfile import open as tarfile_open from time import mktime from zipfile import ZipFile @@ -39,6 +39,9 @@ class ArchiveBase(object): def after_extract(self, item, dest_dir): pass + def close(self): + self._afo.close() + class TARArchive(ArchiveBase): @@ -76,28 +79,32 @@ class ZIPArchive(ArchiveBase): class FileUnpacker(object): - def __init__(self, archpath, dest_dir="."): - self._archpath = archpath - self._dest_dir = dest_dir + def __init__(self, archpath): + self.archpath = archpath self._unpacker = None - _, archext = splitext(archpath.lower()) - if archext in (".gz", ".bz2"): - self._unpacker = TARArchive(archpath) - elif archext == ".zip": - self._unpacker = ZIPArchive(archpath) - + def __enter__(self): + if self.archpath.lower().endswith((".gz", ".bz2")): + self._unpacker = TARArchive(self.archpath) + elif self.archpath.lower().endswith(".zip"): + self._unpacker = ZIPArchive(self.archpath) if not self._unpacker: - raise UnsupportedArchiveType(archpath) + raise UnsupportedArchiveType(self.archpath) + return self - def start(self): + def __exit__(self, *args): + if self._unpacker: + self._unpacker.close() + + def unpack(self, dest_dir="."): + assert self._unpacker if app.is_disabled_progressbar(): click.echo("Unpacking...") for item in self._unpacker.get_items(): - self._unpacker.extract_item(item, self._dest_dir) + self._unpacker.extract_item(item, dest_dir) else: items = self._unpacker.get_items() with click.progressbar(items, label="Unpacking") as pb: for item in pb: - self._unpacker.extract_item(item, self._dest_dir) + self._unpacker.extract_item(item, dest_dir) return True From 1fab2a5bec63d8b57859febc13b052439920963f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 24 Sep 2017 00:33:35 +0300 Subject: [PATCH 078/211] Bump version to 3.5.0a16 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 3e961553..bc41dc87 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a15") +VERSION = (3, 5, "0a16") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From a0626ac958b92fa84e3ee39ddcb5a01e18af2473 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 24 Sep 2017 01:28:41 +0300 Subject: [PATCH 079/211] Hint user to delete file manually when exception is raised --- platformio/__main__.py | 2 +- platformio/commands/upgrade.py | 2 +- platformio/util.py | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/platformio/__main__.py b/platformio/__main__.py index d4da091c..85cbd401 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -118,7 +118,7 @@ def main(): try: configure() cli(None, None, None) - except Exception as e: # pylint: disable=W0703 + except Exception as e: # pylint: disable=broad-except if not isinstance(e, exception.ReturnErrorCode): maintenance.on_platformio_exception(e) error_str = "Error: " diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index df9fc0ee..1faa95ef 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -66,7 +66,7 @@ def cli(): click.echo("Release notes: ", nl=False) click.secho( "http://docs.platformio.org/en/latest/history.html", fg="cyan") - except Exception as e: # pylint: disable=W0703 + except Exception as e: # pylint: disable=broad-except if not r: raise exception.UpgradeError("\n".join([str(cmd), str(e)])) permission_errors = ("permission denied", "not permitted") diff --git a/platformio/util.py b/platformio/util.py index e9dc86c5..4a4027f3 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -627,8 +627,13 @@ def pepver_to_semver(pepver): def rmtree_(path): def _onerror(_, name, __): - os.chmod(name, stat.S_IWRITE) - os.remove(name) + try: + os.chmod(name, stat.S_IWRITE) + os.remove(name) + except Exception as e: # pylint: disable=broad-except + click.secho( + "Please manually remove file `%s`" % name, fg="red", err=True) + raise e return rmtree(path, onerror=_onerror) From 9fe581e425b39de20b66bbb733b6e44bfe622547 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 27 Sep 2017 19:03:04 +0300 Subject: [PATCH 080/211] Update release notes --- HISTORY.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 0bc3ed80..3439b6a8 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,6 +8,8 @@ PlatformIO 3.0 ~~~~~~~~~~~~~~~~~~ * PIO Home +* Depend on development platform using VSC URL (Git, Mercurial and Subversion) + in `Project Configuration File "platformio.ini" `__ * Fixed "Super-Quick (Mac / Linux)" installer script (`issue #1017 `_) * Fixed issue with "IOError" in VSCode when processing a project From 675cd456b672c23538c796cb13bfad129d44fe75 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 27 Sep 2017 19:28:53 +0300 Subject: [PATCH 081/211] New development platform - Samsung ARTIK --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 06439a0d..0ab76245 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 06439a0d5a19ff52b1a4c79f00056056a02dd4f2 +Subproject commit 0ab7624599f77fb0907dcf03ace2d4d3503630e7 From 86de58b9e14599a8ecbbc97312db5f57b51165cf Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 1 Nov 2017 14:09:06 +0200 Subject: [PATCH 082/211] Fix missing toolchain include paths for project generator // Resolve #1154 --- HISTORY.rst | 4 +++- docs | 2 +- platformio/builder/tools/pioide.py | 2 ++ platformio/telemetry.py | 3 +-- tox.ini | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 3439b6a8..dd1c5aea 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -15,6 +15,8 @@ PlatformIO 3.0 * Fixed issue with "IOError" in VSCode when processing a project * Fixed platforms, packages, and libraries updating behind proxy (`issue #1061 `_) +* Fixed missing toolchain include paths for project generator + (`issue #1154 `_) 3.4.1 (2017-08-02) ~~~~~~~~~~~~~~~~~~ @@ -22,7 +24,7 @@ PlatformIO 3.0 * Pre/Post extra scripting for advanced control of PIO Build System (`issue #891 `_) * New `lib_archive `_ - option to control library archiving and linking behaviour + option to control library archiving and linking behavior (`issue #993 `_) * Add "inc" folder automatically to CPPPATH when "src" is available (works for project and library) (`issue #1003 `_) diff --git a/docs b/docs index 0ab76245..1ceb1ce7 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 0ab7624599f77fb0907dcf03ace2d4d3503630e7 +Subproject commit 1ceb1ce7070d67da6ee44d58a5525eb602dd84a2 diff --git a/platformio/builder/tools/pioide.py b/platformio/builder/tools/pioide.py index e05b2d79..66cf5d3d 100644 --- a/platformio/builder/tools/pioide.py +++ b/platformio/builder/tools/pioide.py @@ -41,6 +41,8 @@ def dump_includes(env): toolchain_dir = util.glob_escape(p.get_package_dir(name)) toolchain_incglobs = [ join(toolchain_dir, "*", "include*"), + join(toolchain_dir, "*", "include", "c++", "*"), + join(toolchain_dir, "*", "include", "c++", "*", "*-*-*"), join(toolchain_dir, "lib", "gcc", "*", "*", "include*") ] for g in toolchain_incglobs: diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 7c23e6b5..671fe20c 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -15,7 +15,6 @@ import atexit import platform import Queue -import sys import threading from collections import deque from os import getenv @@ -109,7 +108,7 @@ class MeasurementProtocol(TelemetryBase): self['cd1'] = util.get_systype() self['cd2'] = "Python/%s %s" % (platform.python_version(), platform.platform()) - self['cd3'] = " ".join(_filter_args(sys.argv[1:])) + # self['cd3'] = " ".join(_filter_args(sys.argv[1:])) self['cd4'] = 1 if (not util.is_ci() and (caller_id or not util.is_container())) else 0 if caller_id: diff --git a/tox.ini b/tox.ini index 1232e76c..9cd861e6 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,7 @@ usedevelop = True deps = isort flake8 - yapf<0.18 + yapf pylint pytest commands = python --version From e5e5ebb7db160c139ce1cb20ac8cf4ab20ceef0a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 1 Nov 2017 14:10:32 +0200 Subject: [PATCH 083/211] YAPF formatter --- platformio/builder/tools/piolib.py | 6 ++++-- platformio/builder/tools/pioupload.py | 4 ++-- platformio/builder/tools/platformio.py | 6 ++---- platformio/commands/lib.py | 8 ++++---- platformio/commands/run.py | 12 ++++++------ platformio/commands/settings.py | 4 ++-- platformio/commands/upgrade.py | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 391b5084..f7635c4c 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -237,8 +237,10 @@ class LibBuilderBase(object): self.env.SConscriptChdir(1) self.env.SConscript( realpath(self.extra_script), - exports={"env": self.env, - "pio_lib_builder": self}) + exports={ + "env": self.env, + "pio_lib_builder": self + }) def _process_dependencies(self): if not self.dependencies: diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index 0ff3cb1f..f7edf27a 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -108,8 +108,8 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument def _look_for_mbed_disk(): msdlabels = ("mbed", "nucleo", "frdm", "microbit") for item in util.get_logicaldisks(): - if item['disk'].startswith( - "/net") or not _is_match_pattern(item['disk']): + if item['disk'].startswith("/net") or not _is_match_pattern( + item['disk']): continue mbed_pages = [ join(item['disk'], n) for n in ("mbed.htm", "mbed.html") diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index cbe4c3e5..1a35a4b6 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -35,10 +35,8 @@ SRC_FILTER_DEFAULT = ["+<*>", "-<.git%s>" % sep, "-" % sep] def BuildProgram(env): def _append_pio_macros(): - env.AppendUnique(CPPDEFINES=[ - ("PLATFORMIO", - int("{0:02d}{1:02d}{2:02d}".format(*pioversion_to_intstr()))) - ]) + env.AppendUnique(CPPDEFINES=[("PLATFORMIO", int( + "{0:02d}{1:02d}{2:02d}".format(*pioversion_to_intstr())))]) _append_pio_macros() diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index 997e39ed..e18ba3e7 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -234,8 +234,8 @@ def lib_search(query, json_output, page, noninteractive, **filters): for item in result['items']: print_lib_item(item) - if (int(result['page']) * int(result['perpage']) >= - int(result['total'])): + if (int(result['page']) * int(result['perpage']) >= int( + result['total'])): break if noninteractive: @@ -438,8 +438,8 @@ def lib_stats(json_output): printitem_tpl.format( name=click.style(name, fg="cyan"), url=click.style( - "http://platformio.org/lib/search?query=" + quote( - "keyword:%s" % name), + "http://platformio.org/lib/search?query=" + + quote("keyword:%s" % name), fg="blue"))) for key in ("updated", "added"): diff --git a/platformio/commands/run.py b/platformio/commands/run.py index e27aa455..f5a7683b 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -278,10 +278,10 @@ class EnvironmentProcessor(object): if d.strip() ], self.verbose) if "lib_deps" in self.options: - _autoinstall_libdeps( - self.cmd_ctx, - util.parse_conf_multi_values(self.options['lib_deps']), - self.verbose) + _autoinstall_libdeps(self.cmd_ctx, + util.parse_conf_multi_values( + self.options['lib_deps']), + self.verbose) try: p = PlatformFactory.newPlatform(self.options['platform']) @@ -323,8 +323,8 @@ def _clean_pioenvs_dir(pioenvs_dir): # if project's config is modified if (isdir(pioenvs_dir) - and getmtime(join(util.get_project_dir(), "platformio.ini")) > - getmtime(pioenvs_dir)): + and getmtime(join(util.get_project_dir(), + "platformio.ini")) > getmtime(pioenvs_dir)): util.rmtree_(pioenvs_dir) # check project structure diff --git a/platformio/commands/settings.py b/platformio/commands/settings.py index a29d3997..f163ff6d 100644 --- a/platformio/commands/settings.py +++ b/platformio/commands/settings.py @@ -32,8 +32,8 @@ def settings_get(name): click.echo( list_tpl.format( name=click.style("Name", fg="cyan"), - value=(click.style("Value", fg="green") + click.style( - " [Default]", fg="yellow")), + value=(click.style("Value", fg="green") + + click.style(" [Default]", fg="yellow")), description="Description")) click.echo("-" * terminal_width) diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 1faa95ef..95241d7f 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -87,8 +87,8 @@ WARNING! Don't use `sudo` for the rest PlatformIO commands. err=True) raise exception.ReturnErrorCode(1) else: - raise exception.UpgradeError( - "\n".join([str(cmd), r['out'], r['err']])) + raise exception.UpgradeError("\n".join( + [str(cmd), r['out'], r['err']])) def get_latest_version(): From f85202d64cf2520b4ad9e2cca77d6b49336a044a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 1 Nov 2017 14:14:03 +0200 Subject: [PATCH 084/211] Bump version to 3.5.0a17 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index bc41dc87..9306e2e7 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a16") +VERSION = (3, 5, "0a17") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From b670ab488864f92c198079dc54319ad016052b94 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 2 Nov 2017 23:14:32 +0200 Subject: [PATCH 085/211] Initial support for non-ascii locales --- docs | 2 +- platformio/builder/main.py | 3 ++- platformio/builder/tools/pioide.py | 4 ++-- platformio/commands/home.py | 6 +++++- platformio/downloader.py | 5 +++-- platformio/ide/projectgenerator.py | 24 +++++++++++------------- platformio/managers/core.py | 4 ++-- platformio/managers/package.py | 5 +++-- platformio/util.py | 9 ++------- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/docs b/docs index 1ceb1ce7..06258ad9 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 1ceb1ce7070d67da6ee44d58a5525eb602dd84a2 +Subproject commit 06258ad914f9bf7a15f51274fde9e7bec659c750 diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 094c279f..9d0228d2 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -170,7 +170,8 @@ if "envdump" in COMMAND_LINE_TARGETS: if "idedata" in COMMAND_LINE_TARGETS: try: - print "\n%s\n" % json.dumps(env.DumpIDEData()) + print "\n%s\n" % util.path_to_unicode( + json.dumps(env.DumpIDEData(), ensure_ascii=False)) env.Exit(0) except UnicodeDecodeError: sys.stderr.write( diff --git a/platformio/builder/tools/pioide.py b/platformio/builder/tools/pioide.py index 66cf5d3d..da40bef9 100644 --- a/platformio/builder/tools/pioide.py +++ b/platformio/builder/tools/pioide.py @@ -64,8 +64,8 @@ def dump_defines(env): # special symbol for Atmel AVR MCU if env['PIOPLATFORM'] == "atmelavr": defines.append( - "__AVR_%s__" % env.BoardConfig().get("build.mcu").upper() - .replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny")) + str("__AVR_%s__" % env.BoardConfig().get("build.mcu").upper() + .replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny"))) return defines diff --git a/platformio/commands/home.py b/platformio/commands/home.py index 328298e9..cd6b86f6 100644 --- a/platformio/commands/home.py +++ b/platformio/commands/home.py @@ -20,8 +20,12 @@ from platformio.managers.core import pioplus_call @click.command("home", short_help="PIO Home") +@click.option("--port", type=int, default=8008, help="HTTP port, default=8008") @click.option( - "--port", "-p", type=int, default=8008, help="HTTP port, default=8008") + "--host", + default="127.0.0.1", + help="HTTP host, default=127.0.0.1. " + "You can open PIO Home for inbound connections with --host=0.0.0.0") @click.option("--no-open", is_flag=True) def cli(*args, **kwargs): # pylint: disable=unused-argument pioplus_call(sys.argv[1:]) diff --git a/platformio/downloader.py b/platformio/downloader.py index 9a3b85d9..d7f3ed47 100644 --- a/platformio/downloader.py +++ b/platformio/downloader.py @@ -15,7 +15,7 @@ from email.utils import parsedate_tz from math import ceil from os.path import getsize, join -from sys import version_info +from sys import getfilesystemencoding, version_info from time import mktime import click @@ -53,7 +53,8 @@ class FileDownloader(object): self._progressbar = None self._destination = self._fname if dest_dir: - self.set_destination(join(dest_dir, self._fname)) + self.set_destination( + join(dest_dir.decode(getfilesystemencoding()), self._fname)) def set_destination(self, destination): self._destination = destination diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index 1561bc6e..7a7ce7fb 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -15,11 +15,10 @@ import json import os import re -from cStringIO import StringIO from os.path import abspath, basename, expanduser, isdir, isfile, join, relpath import bottle -import click +from click.testing import CliRunner from platformio import exception, util from platformio.commands.run import cli as cmd_run @@ -65,19 +64,18 @@ class ProjectGenerator(object): if not envdata: return data - out = StringIO() - with util.capture_stdout(out): - click.get_current_context().invoke( - cmd_run, - project_dir=self.project_dir, - environment=[envdata['env_name']], - target=["idedata"]) - result = out.getvalue() + result = CliRunner().invoke(cmd_run, [ + "--project-dir", self.project_dir, "--environment", + envdata['env_name'], "--target", "idedata" + ]) - if '"includes":' not in result: - raise exception.PlatformioException(result) + if result.exit_code != 0 and not isinstance(result.exception, + exception.ReturnErrorCode): + raise result.exception + if '"includes":' not in result.output: + raise exception.PlatformioException(result.output) - for line in result.split("\n"): + for line in result.output.split("\n"): line = line.strip() if line.startswith('{"') and line.endswith("}"): data = json.loads(line) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index a5ddce22..c540771d 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -21,9 +21,9 @@ from platformio import __version__, exception, util from platformio.managers.package import PackageManager CORE_PACKAGES = { - "contrib-piohome": ">=0.3.0,<2", + "contrib-piohome": ">=0.3.2,<2", "pysite-pioplus": ">=0.4.2,<2", - "tool-pioplus": ">=0.10.10,<2", + "tool-pioplus": ">=0.10.13,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" } diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 47e63539..e8788767 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -18,6 +18,7 @@ import json import os import re import shutil +import sys from os.path import basename, getsize, isdir, isfile, islink, join from tempfile import mkdtemp @@ -195,7 +196,7 @@ class PkgInstallerMixin(object): name = re.sub(r"[^\da-z\_\-\. ]", "_", manifest['name'], flags=re.I) if "id" in manifest: name += "_ID%d" % manifest['id'] - return name + return str(name) def get_src_manifest_path(self, pkg_dir): if not isdir(pkg_dir): @@ -258,7 +259,7 @@ class PkgInstallerMixin(object): if "version" not in manifest: manifest['version'] = "0.0.0" - manifest['__pkg_dir'] = pkg_dir + manifest['__pkg_dir'] = util.path_to_unicode(pkg_dir) self.cache_set(cache_key, manifest) return manifest diff --git a/platformio/util.py b/platformio/util.py index 4a4027f3..b3456444 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -21,7 +21,6 @@ import re import stat import subprocess import sys -from contextlib import contextmanager from functools import wraps from glob import glob from os.path import (abspath, basename, dirname, expanduser, isdir, isfile, @@ -180,12 +179,8 @@ def singleton(cls): return get_instance -@contextmanager -def capture_stdout(output): - stdout = sys.stdout - sys.stdout = output - yield - sys.stdout = stdout +def path_to_unicode(path): + return path.decode(sys.getfilesystemencoding()).encode("utf-8") def load_json(file_path): From 0343dc078548894902a9018c30643bd0b021b684 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Nov 2017 00:47:00 +0200 Subject: [PATCH 086/211] Drop flake8 --- platformio/managers/package.py | 1 - tests/commands/test_lib.py | 38 ++++++++++++++++------------------ tox.ini | 3 --- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index e8788767..54f361d0 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -18,7 +18,6 @@ import json import os import re import shutil -import sys from os.path import basename, getsize, isdir, isfile, islink, join from tempfile import mkdtemp diff --git a/tests/commands/test_lib.py b/tests/commands/test_lib.py index 02eac43b..f2b8d725 100644 --- a/tests/commands/test_lib.py +++ b/tests/commands/test_lib.py @@ -14,7 +14,6 @@ import json import re -from os.path import basename from platformio import exception, util from platformio.commands.init import cli as cmd_init @@ -39,7 +38,7 @@ def test_global_install_registry(clirunner, validate_cliresult, result = clirunner.invoke(cmd_lib, [ "-g", "install", "58", "547@2.2.4", "DallasTemperature", "http://dl.platformio.org/libraries/archives/3/5174.tar.gz", - "ArduinoJson@5.6.7", "ArduinoJson@~5.7.0", "1089@fee16e880b" + "ArduinoJson@5.6.7", "ArduinoJson@~5.7.0", "168@00589a3250" ]) validate_cliresult(result) @@ -65,7 +64,7 @@ def test_global_install_registry(clirunner, validate_cliresult, items2 = [ "ArduinoJson_ID64", "ArduinoJson_ID64@5.6.7", "DallasTemperature_ID54", "DHT22_ID58", "ESPAsyncTCP_ID305", "NeoPixelBus_ID547", "OneWire_ID1", - "IRremoteESP8266_ID1089" + "EspSoftwareSerial_ID168" ] assert set(items1) == set(items2) @@ -134,7 +133,7 @@ def test_global_install_repository(clirunner, validate_cliresult, assert "is already installed" in result.output -def test_global_lib_list(clirunner, validate_cliresult, isolated_pio_home): +def test_global_lib_list(clirunner, validate_cliresult): result = clirunner.invoke(cmd_lib, ["-g", "list"]) validate_cliresult(result) assert all([n in result.output for n in ("OneWire", "DHT22", "64")]) @@ -142,31 +141,30 @@ def test_global_lib_list(clirunner, validate_cliresult, isolated_pio_home): result = clirunner.invoke(cmd_lib, ["-g", "list", "--json-output"]) assert all([ n in result.output - for n in ("PJON", "git+https://github.com/knolleary/pubsubclient", - "https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip" - ) + for n in ( + "PJON", "git+https://github.com/knolleary/pubsubclient", + "https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip") ]) items1 = [i['name'] for i in json.loads(result.output)] items2 = [ "OneWire", "DHT22", "PJON", "ESPAsyncTCP", "ArduinoJson", "PubSubClient", "rs485-nodeproto", "Adafruit ST7735 Library", "RadioHead-1.62", "DallasTemperature", "NeoPixelBus", - "IRremoteESP8266", "platformio-libmirror" + "EspSoftwareSerial", "platformio-libmirror" ] assert set(items1) == set(items2) -def test_global_lib_update_check(clirunner, validate_cliresult, - isolated_pio_home): +def test_global_lib_update_check(clirunner, validate_cliresult): result = clirunner.invoke( cmd_lib, ["-g", "update", "--only-check", "--json-output"]) validate_cliresult(result) output = json.loads(result.output) - assert set(["ArduinoJson", "IRremoteESP8266", "NeoPixelBus"]) == set( - [l['name'] for l in output]) + assert set(["ArduinoJson", "EspSoftwareSerial", + "NeoPixelBus"]) == set([l['name'] for l in output]) -def test_global_lib_update(clirunner, validate_cliresult, isolated_pio_home): +def test_global_lib_update(clirunner, validate_cliresult): # update library using package directory result = clirunner.invoke( cmd_lib, @@ -187,7 +185,7 @@ def test_global_lib_update(clirunner, validate_cliresult, isolated_pio_home): assert result.output.count("[Fixed]") == 5 assert result.output.count("[Up-to-date]") == 10 assert "Uninstalling ArduinoJson @ 5.7.3" in result.output - assert "Uninstalling IRremoteESP8266 @ fee16e880b" in result.output + assert "Uninstalling EspSoftwareSerial @ 00589a3250" in result.output # update unknown library result = clirunner.invoke(cmd_lib, ["-g", "update", "Unknown"]) @@ -208,14 +206,14 @@ def test_global_lib_uninstall(clirunner, validate_cliresult, # uninstall the rest libraries result = clirunner.invoke(cmd_lib, [ - "-g", "uninstall", "1", "ArduinoJson@!=5.6.7", - "https://github.com/bblanchon/ArduinoJson.git", "IRremoteESP8266@>=0.2" + "-g", "uninstall", "1", "https://github.com/bblanchon/ArduinoJson.git", + "ArduinoJson@!=5.6.7", "EspSoftwareSerial@>=3.3.1" ]) validate_cliresult(result) items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()] items2 = [ - "ArduinoJson", "ArduinoJson_ID64@5.6.7", "DallasTemperature_ID54", + "ArduinoJson_ID64", "ArduinoJson_ID64@5.6.7", "DallasTemperature_ID54", "DHT22_ID58", "ESPAsyncTCP_ID305", "NeoPixelBus_ID547", "PJON", "PJON@src-79de467ebe19de18287becff0a1fb42d", "PubSubClient", "RadioHead-1.62", "rs485-nodeproto", "platformio-libmirror" @@ -228,7 +226,7 @@ def test_global_lib_uninstall(clirunner, validate_cliresult, assert isinstance(result.exception, exception.UnknownPackage) -def test_lib_show(clirunner, validate_cliresult, isolated_pio_home): +def test_lib_show(clirunner, validate_cliresult): result = clirunner.invoke(cmd_lib, ["show", "64"]) validate_cliresult(result) assert all( @@ -238,14 +236,14 @@ def test_lib_show(clirunner, validate_cliresult, isolated_pio_home): assert "OneWire" in result.output -def test_lib_builtin(clirunner, validate_cliresult, isolated_pio_home): +def test_lib_builtin(clirunner, validate_cliresult): result = clirunner.invoke(cmd_lib, ["builtin"]) validate_cliresult(result) result = clirunner.invoke(cmd_lib, ["builtin", "--json-output"]) validate_cliresult(result) -def test_lib_stats(clirunner, validate_cliresult, isolated_pio_home): +def test_lib_stats(clirunner, validate_cliresult): result = clirunner.invoke(cmd_lib, ["stats"]) validate_cliresult(result) assert all([ diff --git a/tox.ini b/tox.ini index 9cd861e6..ad3288c7 100644 --- a/tox.ini +++ b/tox.ini @@ -20,7 +20,6 @@ basepython = python2.7 usedevelop = True deps = isort - flake8 yapf pylint pytest @@ -47,10 +46,8 @@ commands = [testenv:lint] basepython = python2.7 deps = - flake8 pylint commands = - flake8 ./platformio pylint --rcfile=./.pylintrc ./platformio [testenv] From 909b773f6d112b6a25708e1daa89cdb1192109ea Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Nov 2017 00:51:28 +0200 Subject: [PATCH 087/211] Bump version to 3.5.0b1 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 9306e2e7..2ac27aa7 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0a17") +VERSION = (3, 5, "0b1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 1c9fe4561a21e79499ebba1ea678c8560f7f70f5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Nov 2017 23:10:39 +0200 Subject: [PATCH 088/211] Terminate PIO Home servers when upgrade PIO Core // Issue #1132 --- platformio/commands/home.py | 11 +++++ platformio/commands/upgrade.py | 87 ++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 42 deletions(-) diff --git a/platformio/commands/home.py b/platformio/commands/home.py index cd6b86f6..ae797781 100644 --- a/platformio/commands/home.py +++ b/platformio/commands/home.py @@ -15,6 +15,7 @@ import sys import click +import requests from platformio.managers.core import pioplus_call @@ -29,3 +30,13 @@ from platformio.managers.core import pioplus_call @click.option("--no-open", is_flag=True) def cli(*args, **kwargs): # pylint: disable=unused-argument pioplus_call(sys.argv[1:]) + + +def shutdown_servers(): + port = 8010 + while port < 9000: + try: + requests.get("http://127.0.0.1:%d?__shutdown__=1" % port) + port += 1 + except: # pylint: disable=bare-except + return diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 95241d7f..9cbb6611 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -18,6 +18,7 @@ import click import requests from platformio import VERSION, __version__, exception, util +from platformio.commands.home import shutdown_servers from platformio.managers.core import update_core_packages @@ -33,47 +34,49 @@ def cli(): "You're up-to-date!\nPlatformIO %s is currently the " "newest version available." % __version__, fg="green") - else: - click.secho("Please wait while upgrading PlatformIO ...", fg="yellow") - to_develop = not all([c.isdigit() for c in latest if c != "."]) - cmds = ([ - "pip", "install", "--upgrade", - "https://github.com/platformio/platformio-core/archive/develop.zip" - if to_develop else "platformio" - ], ["platformio", "--version"]) + click.secho("Please wait while upgrading PlatformIO ...", fg="yellow") - cmd = None - r = None - try: - for cmd in cmds: - cmd = [util.get_pythonexe_path(), "-m"] + cmd - r = None + # kill all PIO Home servers, they block `pioplus` binary + shutdown_servers() + + to_develop = not all([c.isdigit() for c in latest if c != "."]) + cmds = ([ + "pip", "install", "--upgrade", + "https://github.com/platformio/platformio-core/archive/develop.zip" + if to_develop else "platformio" + ], ["platformio", "--version"]) + + cmd = None + r = None + try: + for cmd in cmds: + cmd = [util.get_pythonexe_path(), "-m"] + cmd + r = None + r = util.exec_command(cmd) + + # try pip with disabled cache + if r['returncode'] != 0 and cmd[2] == "pip": + cmd.insert(3, "--no-cache-dir") r = util.exec_command(cmd) - # try pip with disabled cache - if r['returncode'] != 0 and cmd[2] == "pip": - cmd.insert(3, "--no-cache-dir") - r = util.exec_command(cmd) - - assert r['returncode'] == 0 - assert "version" in r['out'] - actual_version = r['out'].strip().split("version", 1)[1].strip() + assert r['returncode'] == 0 + assert "version" in r['out'] + actual_version = r['out'].strip().split("version", 1)[1].strip() + click.secho( + "PlatformIO has been successfully upgraded to %s" % actual_version, + fg="green") + click.echo("Release notes: ", nl=False) + click.secho( + "http://docs.platformio.org/en/latest/history.html", fg="cyan") + except Exception as e: # pylint: disable=broad-except + if not r: + raise exception.UpgradeError("\n".join([str(cmd), str(e)])) + permission_errors = ("permission denied", "not permitted") + if (any([m in r['err'].lower() for m in permission_errors]) + and "windows" not in util.get_systype()): click.secho( - "PlatformIO has been successfully upgraded to %s" % - actual_version, - fg="green") - click.echo("Release notes: ", nl=False) - click.secho( - "http://docs.platformio.org/en/latest/history.html", fg="cyan") - except Exception as e: # pylint: disable=broad-except - if not r: - raise exception.UpgradeError("\n".join([str(cmd), str(e)])) - permission_errors = ("permission denied", "not permitted") - if (any([m in r['err'].lower() for m in permission_errors]) - and "windows" not in util.get_systype()): - click.secho( - """ + """ ----------------- Permission denied ----------------- @@ -83,12 +86,12 @@ You need the `sudo` permission to install Python packages. Try WARNING! Don't use `sudo` for the rest PlatformIO commands. """, - fg="yellow", - err=True) - raise exception.ReturnErrorCode(1) - else: - raise exception.UpgradeError("\n".join( - [str(cmd), r['out'], r['err']])) + fg="yellow", + err=True) + raise exception.ReturnErrorCode(1) + else: + raise exception.UpgradeError("\n".join( + [str(cmd), r['out'], r['err']])) def get_latest_version(): From 75770bcedfcf20990f8daf358250c0e36496c775 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Nov 2017 23:11:44 +0200 Subject: [PATCH 089/211] Bump version to 3.5.0b2 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 2ac27aa7..e1290b92 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0b1") +VERSION = (3, 5, "0b2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 25f52917ef29036f26e95817d2d3d001f1357501 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Nov 2017 23:38:09 +0200 Subject: [PATCH 090/211] Override VSCode IntelliSense mode with `clang-x64` --- platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl index 5fea5091..ced616b7 100644 --- a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl +++ b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl @@ -31,7 +31,8 @@ "{{!define.replace('"', '\\"')}}", % end "" - ] + ], + "intelliSenseMode": "clang-x64" } ] } \ No newline at end of file From 4504a65b92aeffdd71fc8e7e528a8771d74206bc Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 4 Nov 2017 00:38:49 +0200 Subject: [PATCH 091/211] Add Black Magic Probe rules --- scripts/99-platformio-udev.rules | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/99-platformio-udev.rules b/scripts/99-platformio-udev.rules index 7adfcf0c..5703cd26 100644 --- a/scripts/99-platformio-udev.rules +++ b/scripts/99-platformio-udev.rules @@ -91,3 +91,7 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f432", MODE="0666 # CMSIS-DAP compatible adapters ATTRS{product}=="*CMSIS-DAP*", MODE="664", GROUP="plugdev" + +# Black Magic Probe +SUBSYSTEM=="tty", ATTRS{interface}=="Black Magic GDB Server" +SUBSYSTEM=="tty", ATTRS{interface}=="Black Magic UART Port" From 5d2867d8a924de9d27357d57079a1c9508426b75 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 7 Nov 2017 00:10:48 +0200 Subject: [PATCH 092/211] Automatically detect BlackMagic probe GDB port --- platformio/builder/tools/pioupload.py | 10 +++++++--- platformio/managers/platform.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index f7edf27a..d4d0818e 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -116,20 +116,23 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument ] if any([isfile(p) for p in mbed_pages]): return item['disk'] - if (item['name'] - and any([l in item['name'].lower() for l in msdlabels])): + if item['name'] \ + and any([l in item['name'].lower() for l in msdlabels]): return item['disk'] return None def _look_for_serial_port(): port = None board_hwids = [] + upload_protocol = env.subst("$UPLOAD_PROTOCOL") if "BOARD" in env and "build.hwids" in env.BoardConfig(): board_hwids = env.BoardConfig().get("build.hwids") for item in util.get_serialports(filter_hwid=True): if not _is_match_pattern(item['port']): continue port = item['port'] + if upload_protocol.startswith("blackmagic") and "GDB" in port: + return port for hwid in board_hwids: hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "") if hwid_str in item['hwid']: @@ -140,7 +143,8 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument print env.subst("Use manually specified: $UPLOAD_PORT") return - if "mbed" in env.subst("$PIOFRAMEWORK"): + if "mbed" in env.subst("$PIOFRAMEWORK") \ + and not env.subst("$UPLOAD_PROTOCOL"): env.Replace(UPLOAD_PORT=_look_for_mbed_disk()) else: if (system() == "Linux" and not any([ diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index dcaf7162..32407a05 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -512,8 +512,8 @@ class PlatformBase( # pylint: disable=too-many-public-methods config = PlatformBoardConfig(manifest_path) if "platform" in config and config.get("platform") != self.name: return - elif ("platforms" in config - and self.name not in config.get("platforms")): + elif "platforms" in config \ + and self.name not in config.get("platforms"): return config.manifest['platform'] = self.name self._BOARDS_CACHE[board_id] = config From d1a2dba68c8e530e273ca68dc8e9bdf2826bbdf2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 7 Nov 2017 23:47:23 +0200 Subject: [PATCH 093/211] Integration with Jenkins CI --- HISTORY.rst | 1 + docs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index dd1c5aea..4d836f22 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,6 +8,7 @@ PlatformIO 3.0 ~~~~~~~~~~~~~~~~~~ * PIO Home +* Integration with `Jenkins CI `_ * Depend on development platform using VSC URL (Git, Mercurial and Subversion) in `Project Configuration File "platformio.ini" `__ * Fixed "Super-Quick (Mac / Linux)" installer script diff --git a/docs b/docs index 06258ad9..98560066 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 06258ad914f9bf7a15f51274fde9e7bec659c750 +Subproject commit 98560066e977189b05fb3cd647a56bb2b372879b From 4c170b7934e6ab88e2f1fba941919ccdf2923b3c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 8 Nov 2017 00:38:19 +0200 Subject: [PATCH 094/211] Ensure real dev/platform name before build process // Resolve #1170 --- platformio/builder/tools/piolib.py | 4 ++-- platformio/builder/tools/pioplatform.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index f7635c4c..6f9c7e25 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -613,8 +613,8 @@ def GetLibBuilders(env): # pylint: disable=too-many-branches items = [] compat_mode = int(env.get("LIB_COMPAT_MODE", 1)) - verbose = (int(ARGUMENTS.get("PIOVERBOSE", 0)) - and not env.GetOption('clean')) + verbose = int(ARGUMENTS.get("PIOVERBOSE", + 0)) and not env.GetOption('clean') def _check_lib_builder(lb): if lb.name in env.get("LIB_IGNORE", []): diff --git a/platformio/builder/tools/pioplatform.py b/platformio/builder/tools/pioplatform.py index ab679a68..1b7cf377 100644 --- a/platformio/builder/tools/pioplatform.py +++ b/platformio/builder/tools/pioplatform.py @@ -61,6 +61,9 @@ def LoadPioPlatform(env, variables): p = env.PioPlatform() installed_packages = p.get_installed_packages() + # Ensure real platform name + env['PIOPLATFORM'] = p.name + # Add toolchains and uploaders to $PATH for name in installed_packages: type_ = p.get_package_type(name) @@ -80,9 +83,8 @@ def LoadPioPlatform(env, variables): board_config = env.BoardConfig() for k in variables.keys(): - if (k in env - or not any([k.startswith("BOARD_"), - k.startswith("UPLOAD_")])): + if k in env or \ + not any([k.startswith("BOARD_"), k.startswith("UPLOAD_")]): continue _opt, _val = k.lower().split("_", 1) if _opt == "board": From ce9c563c9f5c89a5588f0e98e3551e09306043c1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 8 Nov 2017 00:39:25 +0200 Subject: [PATCH 095/211] Bump version to 3.5.0b3 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index e1290b92..4f8c1541 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0b2") +VERSION = (3, 5, "0b3") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 02db510048fcdd0856b9fd29492c081bfda3d697 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 8 Nov 2017 11:22:44 +0200 Subject: [PATCH 096/211] Check serial device description when looking for GDB port --- platformio/builder/tools/pioupload.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index d4d0818e..36fbda8c 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -131,7 +131,8 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument if not _is_match_pattern(item['port']): continue port = item['port'] - if upload_protocol.startswith("blackmagic") and "GDB" in port: + if upload_protocol.startswith("blackmagic") \ + and "GDB" in item['description']: return port for hwid in board_hwids: hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "") From 8b4104bf5b96065da5c4422fa5931c141554990b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 22 Nov 2017 21:09:16 +0200 Subject: [PATCH 097/211] YAPF --- platformio/app.py | 5 +++-- platformio/builder/main.py | 5 +++-- platformio/builder/tools/platformio.py | 5 +++-- platformio/commands/run.py | 15 ++++++++------- platformio/managers/core.py | 12 +++++------- platformio/managers/package.py | 2 +- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/platformio/app.py b/platformio/app.py index f4e5ea2b..b4e62452 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -354,7 +354,8 @@ def get_cid(): except: # pylint: disable=bare-except pass cid = str( - uuid.UUID(bytes=hashlib.md5(str(_uid if _uid else uuid.getnode())) - .digest())) + uuid.UUID( + bytes=hashlib.md5(str(_uid if _uid else uuid.getnode())) + .digest())) set_state_item("cid", cid) return cid diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 9d0228d2..e355f68d 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -138,8 +138,9 @@ for var in ("BUILD_FLAGS", "SRC_BUILD_FLAGS", "SRC_FILTER", "EXTRA_SCRIPTS", # Configure extra library source directories for LDF if util.get_project_optional_dir("lib_extra_dirs"): - env.Prepend(LIBSOURCE_DIRS=util.parse_conf_multi_values( - util.get_project_optional_dir("lib_extra_dirs"))) + env.Prepend( + LIBSOURCE_DIRS=util.parse_conf_multi_values( + util.get_project_optional_dir("lib_extra_dirs"))) env.Prepend(LIBSOURCE_DIRS=env.get("LIB_EXTRA_DIRS", [])) env['LIBSOURCE_DIRS'] = [ expanduser(d) if d.startswith("~") else d for d in env['LIBSOURCE_DIRS'] diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 1a35a4b6..67b1d43f 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -35,8 +35,9 @@ SRC_FILTER_DEFAULT = ["+<*>", "-<.git%s>" % sep, "-" % sep] def BuildProgram(env): def _append_pio_macros(): - env.AppendUnique(CPPDEFINES=[("PLATFORMIO", int( - "{0:02d}{1:02d}{2:02d}".format(*pioversion_to_intstr())))]) + env.AppendUnique(CPPDEFINES=[( + "PLATFORMIO", + int("{0:02d}{1:02d}{2:02d}".format(*pioversion_to_intstr())))]) _append_pio_macros() diff --git a/platformio/commands/run.py b/platformio/commands/run.py index f5a7683b..59654de5 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -180,13 +180,14 @@ class EnvironmentProcessor(object): self.options[k] = self.options[k].strip() if not self.silent: - click.echo( - "[%s] Processing %s (%s)" % - (datetime.now().strftime("%c"), - click.style(self.name, fg="cyan", bold=True), "; ".join([ - "%s: %s" % (k, ", ".join(util.parse_conf_multi_values(v))) - for k, v in self.options.items() - ]))) + click.echo("[%s] Processing %s (%s)" % + (datetime.now().strftime("%c"), + click.style(self.name, fg="cyan", bold=True), + "; ".join([ + "%s: %s" % + (k, ", ".join(util.parse_conf_multi_values(v))) + for k, v in self.options.items() + ]))) click.secho("-" * terminal_width, bold=True) self.options = self._validate_options(self.options) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index c540771d..dcf85bd1 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -36,13 +36,11 @@ PIOPLUS_AUTO_UPDATES_MAX = 100 class CorePackageManager(PackageManager): def __init__(self): - PackageManager.__init__( - self, - join(util.get_home_dir(), "packages"), [ - "https://dl.bintray.com/platformio/dl-packages/manifest.json", - "http%s://dl.platformio.org/packages/manifest.json" % - ("" if sys.version_info < (2, 7, 9) else "s") - ]) + PackageManager.__init__(self, join(util.get_home_dir(), "packages"), [ + "https://dl.bintray.com/platformio/dl-packages/manifest.json", + "http%s://dl.platformio.org/packages/manifest.json" % + ("" if sys.version_info < (2, 7, 9) else "s") + ]) def install(self, name, requirements=None, *args, **kwargs): PackageManager.install(self, name, requirements, *args, **kwargs) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 54f361d0..6ee4b820 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -499,8 +499,8 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): url_marker = "://" req_conditions = [ - not requirements, "@" in text, + not requirements, not url_marker.startswith("git") ] # yapf: disable if all(req_conditions): From 1c20efe9d12962e2e29d72192bf27795b88181b4 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 22 Nov 2017 21:38:14 +0200 Subject: [PATCH 098/211] Improve support for dependency with scp-like syntax --- platformio/managers/platform.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 32407a05..9c26a1d7 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -265,6 +265,8 @@ class PlatformPackagesMixin(object): not (skip_default_package or opts.get("optional", False))): if self.is_valid_requirements(version): self.pm.install(name, version, silent=silent) + elif version.startswith("git@"): + self.pm.install(version, silent=silent) else: requirements = None if "@" in version: @@ -294,7 +296,7 @@ class PlatformPackagesMixin(object): def update_packages(self, only_check=False): for name, manifest in self.get_installed_packages().items(): version = self.packages[name].get("version", "") - if "@" in version: + if "@" in version and not version.startswith("git@"): _, version = version.rsplit("@", 1) self.pm.update(manifest['__pkg_dir'], version, only_check) @@ -309,7 +311,7 @@ class PlatformPackagesMixin(object): def are_outdated_packages(self): for name, manifest in self.get_installed_packages().items(): version = self.packages[name].get("version", "") - if "@" in version: + if "@" in version and not version.startswith("git@"): _, version = version.rsplit("@", 1) if self.pm.outdated(manifest['__pkg_dir'], version): return True @@ -329,11 +331,11 @@ class PlatformPackagesMixin(object): @staticmethod def is_valid_requirements(requirements): - return requirements and "://" not in requirements + return requirements and ":" not in requirements def _parse_pkg_input(self, name, version): requirements = None - if "@" in version: + if "@" in version and not version.startswith("git@"): version, requirements = version.rsplit("@", 1) return self.pm.parse_pkg_input("%s=%s" % (name, version), requirements) From 5b5387d97b44b01794244dc77be19e570bab9026 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 24 Nov 2017 15:36:37 +0200 Subject: [PATCH 099/211] Sync docs with the latest added hardware/software --- docs | 2 +- examples | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs b/docs index 98560066..2ed1f256 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 98560066e977189b05fb3cd647a56bb2b372879b +Subproject commit 2ed1f25673a7cc91f023a914acc47786259506dd diff --git a/examples b/examples index de48488c..2998735e 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit de48488cd2497fc2069090f35bc154ec557d51e9 +Subproject commit 2998735ea5870291766161fae7c9ecc611a33d66 From d07833e010996ec902ab5d42f33726eb1ee4a33b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 24 Nov 2017 20:04:18 +0200 Subject: [PATCH 100/211] Include TizenRT to docs --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 2ed1f256..ea486d60 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 2ed1f25673a7cc91f023a914acc47786259506dd +Subproject commit ea486d6022307c2e0bd152c5dd45b03fe4343c31 From 53b37216cc27c4d7b6126f97b4145e9bbaac377c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Nov 2017 00:31:16 +0200 Subject: [PATCH 101/211] Improve support for VCS packages --- docs | 2 +- platformio/commands/lib.py | 4 +- platformio/commands/platform.py | 2 +- platformio/managers/lib.py | 3 +- platformio/managers/package.py | 85 +++++++++++++++++---------------- platformio/managers/platform.py | 53 +++++++------------- tests/test_managers.py | 26 ++++++---- 7 files changed, 84 insertions(+), 91 deletions(-) diff --git a/docs b/docs index ea486d60..0efb6ee6 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit ea486d6022307c2e0bd152c5dd45b03fe4343c31 +Subproject commit 0efb6ee60ca89916b410d53dd36cef3a2f522ab0 diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index e18ba3e7..5a49369b 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -128,7 +128,7 @@ def lib_update(lm, libraries, only_check, json_output): requirements = None url = None if not pkg_dir: - name, requirements, url = lm.parse_pkg_input(library) + name, requirements, url = lm.parse_pkg_uri(library) pkg_dir = lm.get_package_dir(name, requirements, url) if not pkg_dir: continue @@ -314,7 +314,7 @@ def lib_builtin(storage, json_output): @click.option("--json-output", is_flag=True) def lib_show(library, json_output): lm = LibraryManager() - name, requirements, _ = lm.parse_pkg_input(library) + name, requirements, _ = lm.parse_pkg_uri(library) lib_id = lm.get_pkg_id_by_name( name, requirements, silent=json_output, interactive=not json_output) lib = get_api_result("/lib/info/%d" % lib_id, cache_valid="1d") diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index f67cccfc..61584691 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -351,7 +351,7 @@ def platform_update(platforms, only_packages, only_check, json_output): requirements = None url = None if not pkg_dir: - name, requirements, url = pm.parse_pkg_input(platform) + name, requirements, url = pm.parse_pkg_uri(platform) pkg_dir = pm.get_package_dir(name, requirements, url) if not pkg_dir: continue diff --git a/platformio/managers/lib.py b/platformio/managers/lib.py index ad3197a4..d13671ef 100644 --- a/platformio/managers/lib.py +++ b/platformio/managers/lib.py @@ -242,8 +242,7 @@ class LibraryManager(BasePkgManager): interactive=False): pkg_dir = None try: - _name, _requirements, _url = self.parse_pkg_input( - name, requirements) + _name, _requirements, _url = self.parse_pkg_uri(name, requirements) if not _url: name = "id=%d" % self.get_pkg_id_by_name( _name, diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 6ee4b820..a7670109 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -490,51 +490,59 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): click.echo("%s: %s" % (self.__class__.__name__, message), nl=nl) @staticmethod - def parse_pkg_input( # pylint: disable=too-many-branches + def parse_pkg_uri( # pylint: disable=too-many-branches text, requirements=None): text = str(text) - # git@github.com:user/package.git - url_marker = text[:4] - if url_marker not in ("git@", "git+") or ":" not in text: - url_marker = "://" + name, url = None, None + # Parse requirements req_conditions = [ - "@" in text, - not requirements, - not url_marker.startswith("git") - ] # yapf: disable + "@" in text, not requirements, "://" not in text + or text.rfind("/") < text.rfind("@") + ] if all(req_conditions): text, requirements = text.rsplit("@", 1) + + # Handle PIO Library Registry ID if text.isdigit(): text = "id=" + text + # Parse custom name + elif "=" in text and not text.startswith("id="): + name, text = text.split("=", 1) - name, url = (None, text) - if "=" in text and not text.startswith("id="): - name, url = text.split("=", 1) + # Parse URL + # if valid URL with scheme vcs+protocol:// + if "+" in text and text.find("+") < text.find("://"): + url = text + elif "/" in text or "\\" in text: + git_conditions = [ + # Handle GitHub URL (https://github.com/user/package) + text.startswith("https://github.com/") and not text.endswith( + (".zip", ".tar.gz")), + text.startswith("http") + and (text.split("#", 1)[0] + if "#" in text else text).endswith(".git") + ] + hg_conditions = [ + # Handle Developer Mbed URL + # (https://developer.mbed.org/users/user/code/package/) + text.startswith("https://developer.mbed.org") + ] + if any(git_conditions): + url = "git+" + text + elif any(hg_conditions): + url = "hg+" + text + elif "://" not in text and (isfile(text) or isdir(text)): + url = "file://" + text + elif "://" in text: + url = text - git_conditions = [ - # Handle GitHub URL (https://github.com/user/package) - url.startswith("https://github.com/") and not url.endswith( - (".zip", ".tar.gz")), - url.startswith("http") - and (url.split("#", 1)[0] if "#" in url else url).endswith(".git") - ] - if any(git_conditions): - url = "git+" + url + # Handle short version of GitHub URL + if text.count("/") == 1: + url = "git+https://github.com/" + text - # Handle Developer Mbed URL - # (https://developer.mbed.org/users/user/code/package/) - if url.startswith("https://developer.mbed.org"): - url = "hg+" + url - - if any([s in url for s in ("\\", "/")]) and url_marker not in url: - if isfile(url) or isdir(url): - url = "file://" + url - elif url.count("/") == 1 and "git" not in url_marker: - url = "git+https://github.com/" + url - - # determine name - if url_marker in url and not name: + # Parse name from URL + if url and not name: _url = url.split("#", 1)[0] if "#" in url else url if _url.endswith(("\\", "/")): _url = _url[:-1] @@ -542,8 +550,6 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): if "." in name and not name.startswith("."): name = name.rsplit(".", 1)[0] - if url_marker not in url: - url = None return (name or text, requirements, url) def outdated(self, pkg_dir, requirements=None): @@ -607,7 +613,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): return self.INSTALL_HISTORY.append(history_key) - name, requirements, url = self.parse_pkg_input(name, requirements) + name, requirements, url = self.parse_pkg_uri(name, requirements) package_dir = self.get_package_dir(name, requirements, url) if not package_dir or not silent: @@ -653,8 +659,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): if isdir(package): pkg_dir = package else: - name, requirements, url = self.parse_pkg_input( - package, requirements) + name, requirements, url = self.parse_pkg_uri(package, requirements) pkg_dir = self.get_package_dir(name, requirements, url) if not pkg_dir: @@ -694,7 +699,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): if isdir(package): pkg_dir = package else: - pkg_dir = self.get_package_dir(*self.parse_pkg_input(package)) + pkg_dir = self.get_package_dir(*self.parse_pkg_uri(package)) if not pkg_dir: raise exception.UnknownPackage("%s @ %s" % (package, diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 9c26a1d7..dfd601fd 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -84,8 +84,7 @@ class PlatformManager(BasePkgManager): if isdir(package): pkg_dir = package else: - name, requirements, url = self.parse_pkg_input( - package, requirements) + name, requirements, url = self.parse_pkg_uri(package, requirements) pkg_dir = self.get_package_dir(name, requirements, url) p = PlatformFactory.newPlatform(pkg_dir) @@ -108,8 +107,7 @@ class PlatformManager(BasePkgManager): if isdir(package): pkg_dir = package else: - name, requirements, url = self.parse_pkg_input( - package, requirements) + name, requirements, url = self.parse_pkg_uri(package, requirements) pkg_dir = self.get_package_dir(name, requirements, url) p = PlatformFactory.newPlatform(pkg_dir) @@ -219,7 +217,7 @@ class PlatformFactory(object): platform_dir = dirname(name) name = util.load_json(name)['name'] else: - name, requirements, url = pm.parse_pkg_input(name, requirements) + name, requirements, url = pm.parse_pkg_uri(name, requirements) platform_dir = pm.get_package_dir(name, requirements, url) if platform_dir: name = pm.load_manifest(platform_dir)['name'] @@ -263,16 +261,10 @@ class PlatformPackagesMixin(object): continue elif (name in with_packages or not (skip_default_package or opts.get("optional", False))): - if self.is_valid_requirements(version): - self.pm.install(name, version, silent=silent) - elif version.startswith("git@"): - self.pm.install(version, silent=silent) + if "://" in version: + self.pm.install("%s=%s" % (name, version), silent=silent) else: - requirements = None - if "@" in version: - version, requirements = version.rsplit("@", 1) - self.pm.install( - "%s=%s" % (name, version), requirements, silent=silent) + self.pm.install(name, version, silent=silent) return True @@ -295,10 +287,10 @@ class PlatformPackagesMixin(object): def update_packages(self, only_check=False): for name, manifest in self.get_installed_packages().items(): - version = self.packages[name].get("version", "") - if "@" in version and not version.startswith("git@"): - _, version = version.rsplit("@", 1) - self.pm.update(manifest['__pkg_dir'], version, only_check) + requirements = self.packages[name].get("version", "") + if "://" in requirements: + _, requirements, __ = self.parse_pkg_uri(requirements) + self.pm.update(manifest['__pkg_dir'], requirements, only_check) def get_installed_packages(self): items = {} @@ -310,18 +302,19 @@ class PlatformPackagesMixin(object): def are_outdated_packages(self): for name, manifest in self.get_installed_packages().items(): - version = self.packages[name].get("version", "") - if "@" in version and not version.startswith("git@"): - _, version = version.rsplit("@", 1) - if self.pm.outdated(manifest['__pkg_dir'], version): + requirements = self.packages[name].get("version", "") + if "://" in requirements: + _, requirements, __ = self.parse_pkg_uri(requirements) + if self.pm.outdated(manifest['__pkg_dir'], requirements): return True return False def get_package_dir(self, name): version = self.packages[name].get("version", "") - if self.is_valid_requirements(version): - return self.pm.get_package_dir(name, version) - return self.pm.get_package_dir(*self._parse_pkg_input(name, version)) + if "://" in version: + return self.pm.get_package_dir(*self.pm.parse_pkg_uri( + "%s=%s" % (name, version))) + return self.pm.get_package_dir(name, version) def get_package_version(self, name): pkg_dir = self.get_package_dir(name) @@ -329,16 +322,6 @@ class PlatformPackagesMixin(object): return None return self.pm.load_manifest(pkg_dir).get("version") - @staticmethod - def is_valid_requirements(requirements): - return requirements and ":" not in requirements - - def _parse_pkg_input(self, name, version): - requirements = None - if "@" in version and not version.startswith("git@"): - version, requirements = version.rsplit("@", 1) - return self.pm.parse_pkg_input("%s=%s" % (name, version), requirements) - class PlatformRunMixin(object): diff --git a/tests/test_managers.py b/tests/test_managers.py index a26742bc..b680b771 100644 --- a/tests/test_managers.py +++ b/tests/test_managers.py @@ -115,14 +115,14 @@ def test_pkg_input_parser(): "hg+https://example.com/user/package", ("package", None, "hg+https://example.com/user/package") ], - [ - "git@github.com:user/package.git", - ("package", None, "git@github.com:user/package.git") - ], - [ - "git@github.com:user/package.git#v1.2.0", - ("package", None, "git@github.com:user/package.git#v1.2.0") - ], + # [ + # "git@github.com:user/package.git", + # ("package", None, "git@github.com:user/package.git") + # ], + # [ + # "git@github.com:user/package.git#v1.2.0", + # ("package", None, "git@github.com:user/package.git#v1.2.0") + # ], [ "git+ssh://git@gitlab.private-server.com/user/package#1.2.0", ("package", None, @@ -132,13 +132,19 @@ def test_pkg_input_parser(): "git+ssh://user@gitlab.private-server.com:1234/package#1.2.0", ("package", None, "git+ssh://user@gitlab.private-server.com:1234/package#1.2.0") + ], + [ + "LocalName=git+ssh://user@gitlab.private-server.com:1234" + "/package#1.2.0@!=13", + ("LocalName", "!=13", + "git+ssh://user@gitlab.private-server.com:1234/package#1.2.0") ] ] for params, result in items: if isinstance(params, tuple): - assert PackageManager.parse_pkg_input(*params) == result + assert PackageManager.parse_pkg_uri(*params) == result else: - assert PackageManager.parse_pkg_input(params) == result + assert PackageManager.parse_pkg_uri(params) == result def test_install_packages(isolated_pio_home, tmpdir): From fc96806e68b5fd9c5e1cfbddbf9958f787719821 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Nov 2017 01:02:27 +0200 Subject: [PATCH 102/211] Update docs for ESP32 with custom options --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 0efb6ee6..19f487e4 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 0efb6ee60ca89916b410d53dd36cef3a2f522ab0 +Subproject commit 19f487e4c415859047f61262fac5a4fa888c590b From a983f60fa05201cd7e30028d4861148e55486f39 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Nov 2017 01:12:49 +0200 Subject: [PATCH 103/211] Bump version to 3.5.0b4 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 4f8c1541..c0e7bcd4 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0b3") +VERSION = (3, 5, "0b4") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 37a2ccedbde0332643d5cfe1904625eccf35cc86 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Nov 2017 15:11:06 +0200 Subject: [PATCH 104/211] Temporary fix for Arrow with a missing deps to backports.functools-lru-cache --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 116656cc..1e76c119 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,8 @@ install_requires = [ "lockfile>=0.9.1,<0.13", "pyserial>=3,<4,!=3.3", "requests>=2.4.0,<3", - "semantic_version>=2.5.0" + "semantic_version>=2.5.0", + "backports.functools-lru-cache" # tmp for for arrow ] setup( From 9b514ba19420026ced8f79eb02cdb3bfcb401639 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Nov 2017 19:06:38 +0200 Subject: [PATCH 105/211] Remove temporary hook for Arrow deps --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 1e76c119..1a15963e 100644 --- a/setup.py +++ b/setup.py @@ -25,8 +25,7 @@ install_requires = [ "lockfile>=0.9.1,<0.13", "pyserial>=3,<4,!=3.3", "requests>=2.4.0,<3", - "semantic_version>=2.5.0", - "backports.functools-lru-cache" # tmp for for arrow + "semantic_version>=2.5.0,<3" ] setup( From 547e983a8669c1c0cde6b1819e1ce390014cf489 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Nov 2017 19:22:00 +0200 Subject: [PATCH 106/211] Improved handling of library dependencies defined as VCS or SemVer in platformio.ini // Resolve #1155 --- HISTORY.rst | 3 ++ platformio/builder/tools/piolib.py | 61 ++++++++++++++++++++---------- platformio/managers/lib.py | 1 + 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 4d836f22..e5a1adb9 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -11,6 +11,9 @@ PlatformIO 3.0 * Integration with `Jenkins CI `_ * Depend on development platform using VSC URL (Git, Mercurial and Subversion) in `Project Configuration File "platformio.ini" `__ +* Improved handling of library dependencies defined as VCS or SemVer in + `Project Configuration File "platformio.ini" `__ + (`issue #1155 `_) * Fixed "Super-Quick (Mac / Linux)" installer script (`issue #1017 `_) * Fixed issue with "IOError" in VSCode when processing a project diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 6f9c7e25..7cf9aa36 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -19,7 +19,8 @@ from __future__ import absolute_import import os import sys -from os.path import basename, commonprefix, isdir, isfile, join, realpath, sep +from os.path import (basename, commonprefix, dirname, isdir, isfile, join, + realpath, sep) from platform import system import SCons.Scanner @@ -242,7 +243,7 @@ class LibBuilderBase(object): "pio_lib_builder": self }) - def _process_dependencies(self): + def process_dependencies(self): if not self.dependencies: return for item in self.dependencies: @@ -297,15 +298,10 @@ class LibBuilderBase(object): def _get_found_includes(self, search_paths=None): # all include directories if not LibBuilderBase.INC_DIRS_CACHE: - inc_dirs = [] - used_inc_dirs = [] + LibBuilderBase.INC_DIRS_CACHE = [] for lb in self.envorigin.GetLibBuilders(): - items = [self.env.Dir(d) for d in lb.get_inc_dirs()] - if lb.dependent: - used_inc_dirs.extend(items) - else: - inc_dirs.extend(items) - LibBuilderBase.INC_DIRS_CACHE = used_inc_dirs + inc_dirs + LibBuilderBase.INC_DIRS_CACHE.extend( + [self.env.Dir(d) for d in lb.get_inc_dirs()]) # append self include directories inc_dirs = [self.env.Dir(d) for d in self.get_inc_dirs()] @@ -356,7 +352,7 @@ class LibBuilderBase(object): def search_deps_recursive(self, search_paths=None): if not self._is_dependent: self._is_dependent = True - self._process_dependencies() + self.process_dependencies() if self.lib_ldf_mode.startswith("deep"): search_paths = self.get_src_files() @@ -588,17 +584,40 @@ class ProjectAsLibBuilder(LibBuilderBase): # skip for project, options are already processed pass - def search_deps_recursive(self, search_paths=None): - for dep in self.env.get("LIB_DEPS", []): - for token in ("@", "="): - if token in dep: - dep, _ = dep.split(token, 1) - for lb in self.envorigin.GetLibBuilders(): - if lb.name == dep: + def process_dependencies(self): + dependencies = self.env.get("LIB_DEPS", []) + if not dependencies: + return + storage_dirs = [] + for lb in self.env.GetLibBuilders(): + if dirname(lb.path) not in storage_dirs: + storage_dirs.append(dirname(lb.path)) + + for uri in self.env.get("LIB_DEPS", []): + found = False + for storage_dir in storage_dirs: + if found: + break + lm = LibraryManager(storage_dir) + pkg_dir = lm.get_package_dir(*lm.parse_pkg_uri(uri)) + if not pkg_dir: + continue + for lb in self.envorigin.GetLibBuilders(): + if lb.path != pkg_dir: + continue + if lb not in self.depbuilders: + self.depend_recursive(lb) + found = True + break + + if not found: + print 67, uri + for lb in self.envorigin.GetLibBuilders(): + if lb.name != uri: + continue if lb not in self.depbuilders: self.depend_recursive(lb) break - return LibBuilderBase.search_deps_recursive(self, search_paths) def build(self): self._is_built = True # do not build Project now @@ -609,7 +628,9 @@ class ProjectAsLibBuilder(LibBuilderBase): def GetLibBuilders(env): # pylint: disable=too-many-branches if "__PIO_LIB_BUILDERS" in DefaultEnvironment(): - return DefaultEnvironment()['__PIO_LIB_BUILDERS'] + return sorted( + DefaultEnvironment()['__PIO_LIB_BUILDERS'], + key=lambda lb: 0 if lb.dependent else 1) items = [] compat_mode = int(env.get("LIB_COMPAT_MODE", 1)) diff --git a/platformio/managers/lib.py b/platformio/managers/lib.py index d13671ef..193cbca7 100644 --- a/platformio/managers/lib.py +++ b/platformio/managers/lib.py @@ -104,6 +104,7 @@ class LibraryManager(BasePkgManager): "sam": "atmelsam", "samd": "atmelsam", "esp8266": "espressif8266", + "esp32": "espressif32", "arc32": "intel_arc32" } for arch in manifest['architectures'].split(","): From 301b8dc6492c3abe653ef4eed1d09c8335a88d78 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Nov 2017 19:22:47 +0200 Subject: [PATCH 107/211] Bump version to 3.5.0b5 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index c0e7bcd4..f83c490b 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0b4") +VERSION = (3, 5, "0b5") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 0c9c6d10929c14734b529e1f58a5272c5db98fdd Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Nov 2017 19:25:07 +0200 Subject: [PATCH 108/211] Remove debug code --- platformio/builder/tools/piolib.py | 1 - 1 file changed, 1 deletion(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 7cf9aa36..4bede654 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -611,7 +611,6 @@ class ProjectAsLibBuilder(LibBuilderBase): break if not found: - print 67, uri for lb in self.envorigin.GetLibBuilders(): if lb.name != uri: continue From dcab855d2c9fd1ede58880bf78b886f13f9cca09 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Nov 2017 19:59:03 +0200 Subject: [PATCH 109/211] Fix PyLint --- platformio/builder/tools/piolib.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 4bede654..b3b93539 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -584,16 +584,16 @@ class ProjectAsLibBuilder(LibBuilderBase): # skip for project, options are already processed pass - def process_dependencies(self): - dependencies = self.env.get("LIB_DEPS", []) - if not dependencies: + def process_dependencies(self): # pylint: disable=too-many-branches + uris = self.env.get("LIB_DEPS", []) + if not uris: return storage_dirs = [] for lb in self.env.GetLibBuilders(): if dirname(lb.path) not in storage_dirs: storage_dirs.append(dirname(lb.path)) - for uri in self.env.get("LIB_DEPS", []): + for uri in uris: found = False for storage_dir in storage_dirs: if found: From 5ca472050c8584fb9b54e0d3e2fdefc0455daab5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Nov 2017 20:16:37 +0200 Subject: [PATCH 110/211] Typo fix --- platformio/managers/platform.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index dfd601fd..a3d21d01 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -289,7 +289,7 @@ class PlatformPackagesMixin(object): for name, manifest in self.get_installed_packages().items(): requirements = self.packages[name].get("version", "") if "://" in requirements: - _, requirements, __ = self.parse_pkg_uri(requirements) + _, requirements, __ = self.pm.parse_pkg_uri(requirements) self.pm.update(manifest['__pkg_dir'], requirements, only_check) def get_installed_packages(self): @@ -304,7 +304,7 @@ class PlatformPackagesMixin(object): for name, manifest in self.get_installed_packages().items(): requirements = self.packages[name].get("version", "") if "://" in requirements: - _, requirements, __ = self.parse_pkg_uri(requirements) + _, requirements, __ = self.pm.parse_pkg_uri(requirements) if self.pm.outdated(manifest['__pkg_dir'], requirements): return True return False From 9fc5aecb646eab18b5a91b3448740b15eb57f44b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Nov 2017 21:51:16 +0200 Subject: [PATCH 111/211] Add option to configure library Compatible Mode using library.json --- HISTORY.rst | 2 + docs | 2 +- platformio/builder/tools/piolib.py | 67 ++++++++++++++++++++---------- 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index e5a1adb9..6a9b1305 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -14,6 +14,8 @@ PlatformIO 3.0 * Improved handling of library dependencies defined as VCS or SemVer in `Project Configuration File "platformio.ini" `__ (`issue #1155 `_) +* Added option to configure library `Compatible Mode `__ + using `library.json `__ * Fixed "Super-Quick (Mac / Linux)" installer script (`issue #1017 `_) * Fixed issue with "IOError" in VSCode when processing a project diff --git a/docs b/docs index 19f487e4..d14eee32 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 19f487e4c415859047f61262fac5a4fa888c590b +Subproject commit d14eee32547ea30237c32df43aa72987245158d3 diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index b3b93539..f0b86794 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -83,6 +83,9 @@ class LibBuilderBase(object): LDF_MODES = ["off", "chain", "deep", "chain+", "deep+"] LDF_MODE_DEFAULT = "chain" + COMPAT_MODES = [0, 1, 2] + COMPAT_MODE_DEFAULT = 1 + CLASSIC_SCANNER = SCons.Scanner.C.CScanner() ADVANCED_SCANNER = SCons.Scanner.C.CScanner(advanced=True) INC_DIRS_CACHE = None @@ -94,8 +97,6 @@ class LibBuilderBase(object): self.verbose = verbose self._manifest = manifest if manifest else self.load_manifest() - self._ldf_mode = self.validate_ldf_mode( - self.env.get("LIB_LDF_MODE", self.LDF_MODE_DEFAULT)) self._is_dependent = False self._is_built = False self._depbuilders = list() @@ -172,21 +173,15 @@ class LibBuilderBase(object): def lib_archive(self): return self.env.get("LIB_ARCHIVE", "") != "false" - @staticmethod - def validate_ldf_mode(mode): - if isinstance(mode, basestring): - mode = mode.strip().lower() - if mode in LibBuilderBase.LDF_MODES: - return mode - try: - return LibBuilderBase.LDF_MODES[int(mode)] - except (IndexError, ValueError): - pass - return LibBuilderBase.LDF_MODE_DEFAULT - @property def lib_ldf_mode(self): - return self._ldf_mode + return self.validate_ldf_mode( + self.env.get("LIB_LDF_MODE", self.LDF_MODE_DEFAULT)) + + @property + def lib_compat_mode(self): + return self.validate_compat_mode( + self.env.get("LIB_COMPAT_MODE", self.COMPAT_MODE_DEFAULT)) @property def depbuilders(self): @@ -200,6 +195,27 @@ class LibBuilderBase(object): def is_built(self): return self._is_built + @staticmethod + def validate_ldf_mode(mode): + if isinstance(mode, basestring): + mode = mode.strip().lower() + if mode in LibBuilderBase.LDF_MODES: + return mode + try: + return LibBuilderBase.LDF_MODES[int(mode)] + except (IndexError, ValueError): + pass + return LibBuilderBase.LDF_MODE_DEFAULT + + @staticmethod + def validate_compat_mode(mode): + try: + mode = int(mode) + assert mode in LibBuilderBase.COMPAT_MODES + return mode + except (AssertionError, ValueError): + return LibBuilderBase.COMPAT_MODE_DEFAULT + @staticmethod def items_in_list(items, ilist): @@ -263,7 +279,7 @@ class LibBuilderBase(object): continue found = False - for lb in self.envorigin.GetLibBuilders(): + for lb in self.env.GetLibBuilders(): if item['name'] != lb.name: continue elif "frameworks" in item and \ @@ -299,7 +315,7 @@ class LibBuilderBase(object): # all include directories if not LibBuilderBase.INC_DIRS_CACHE: LibBuilderBase.INC_DIRS_CACHE = [] - for lb in self.envorigin.GetLibBuilders(): + for lb in self.env.GetLibBuilders(): LibBuilderBase.INC_DIRS_CACHE.extend( [self.env.Dir(d) for d in lb.get_inc_dirs()]) @@ -363,7 +379,7 @@ class LibBuilderBase(object): lib_inc_map = {} for inc in self._get_found_includes(search_paths): - for lb in self.envorigin.GetLibBuilders(): + for lb in self.env.GetLibBuilders(): if inc.get_abspath() in lb: if lb not in lib_inc_map: lib_inc_map[lb] = [] @@ -391,7 +407,7 @@ class LibBuilderBase(object): self.env.AppendUnique(CPPPATH=self.get_inc_dirs()) if self.lib_ldf_mode == "off": - for lb in self.envorigin.GetLibBuilders(): + for lb in self.env.GetLibBuilders(): if self == lb or not lb.is_built: continue for key in ("CPPPATH", "LIBPATH", "LIBS", "LINKFLAGS"): @@ -535,6 +551,13 @@ class PlatformIOLibBuilder(LibBuilderBase): self._manifest.get("build").get("libLDFMode")) return LibBuilderBase.lib_ldf_mode.fget(self) + @property + def lib_compat_mode(self): + if "libCompatMode" in self._manifest.get("build", {}): + return self.validate_compat_mode( + self._manifest.get("build").get("libCompatMode")) + return LibBuilderBase.lib_compat_mode.fget(self) + def is_platforms_compatible(self, platforms): items = self._manifest.get("platforms") if not items: @@ -602,7 +625,7 @@ class ProjectAsLibBuilder(LibBuilderBase): pkg_dir = lm.get_package_dir(*lm.parse_pkg_uri(uri)) if not pkg_dir: continue - for lb in self.envorigin.GetLibBuilders(): + for lb in self.env.GetLibBuilders(): if lb.path != pkg_dir: continue if lb not in self.depbuilders: @@ -611,7 +634,7 @@ class ProjectAsLibBuilder(LibBuilderBase): break if not found: - for lb in self.envorigin.GetLibBuilders(): + for lb in self.env.GetLibBuilders(): if lb.name != uri: continue if lb not in self.depbuilders: @@ -632,11 +655,11 @@ def GetLibBuilders(env): # pylint: disable=too-many-branches key=lambda lb: 0 if lb.dependent else 1) items = [] - compat_mode = int(env.get("LIB_COMPAT_MODE", 1)) verbose = int(ARGUMENTS.get("PIOVERBOSE", 0)) and not env.GetOption('clean') def _check_lib_builder(lb): + compat_mode = lb.lib_compat_mode if lb.name in env.get("LIB_IGNORE", []): if verbose: sys.stderr.write("Ignored library %s\n" % lb.path) From 02d9272d2a3e0fe2263b1f56610644221663e66f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Nov 2017 23:54:50 +0200 Subject: [PATCH 112/211] Depend on Arrow 0.10.0 (issue with "backports.functools-lru-cache" for PIO Core+) --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1a15963e..dceee7b2 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ from platformio import (__author__, __description__, __email__, __license__, __title__, __url__, __version__) install_requires = [ - "arrow<1", + "arrow==0.10.0", "bottle<0.13", "click>=5,<6", "colorama", From 7b324ebc3c9eba1ef7794004901308ed1ba0f4f5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 Nov 2017 23:55:13 +0200 Subject: [PATCH 113/211] Bump version to 3.5.0b6 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index f83c490b..9652e206 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0b5") +VERSION = (3, 5, "0b6") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From d8ee64a5454304507112dbd08b47e650686cf889 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 26 Nov 2017 01:02:21 +0200 Subject: [PATCH 114/211] Fix tests --- tests/commands/test_platform.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/commands/test_platform.py b/tests/commands/test_platform.py index f6b1771a..2bb747fd 100644 --- a/tests/commands/test_platform.py +++ b/tests/commands/test_platform.py @@ -69,7 +69,7 @@ def test_install_from_vcs(clirunner, validate_cliresult, isolated_pio_home): "platform-espressif8266.git#feature/stage", "--skip-default-package" ]) validate_cliresult(result) - assert "espressif8266_stage" in result.output + assert "espressif8266" in result.output def test_list_json_output(clirunner, validate_cliresult, isolated_pio_home): @@ -79,14 +79,14 @@ def test_list_json_output(clirunner, validate_cliresult, isolated_pio_home): assert isinstance(list_result, list) assert len(list_result) platforms = [item['name'] for item in list_result] - assert set(["atmelavr", "espressif8266_stage"]) == set(platforms) + assert set(["atmelavr", "espressif8266"]) == set(platforms) def test_list_raw_output(clirunner, validate_cliresult, isolated_pio_home): result = clirunner.invoke(cli_platform.platform_list) validate_cliresult(result) assert all( - [s in result.output for s in ("atmelavr", "espressif8266_stage")]) + [s in result.output for s in ("atmelavr", "espressif8266")]) def test_update_check(clirunner, validate_cliresult, isolated_pio_home): @@ -109,6 +109,6 @@ def test_update_raw(clirunner, validate_cliresult, isolated_pio_home): def test_uninstall(clirunner, validate_cliresult, isolated_pio_home): result = clirunner.invoke(cli_platform.platform_uninstall, - ["atmelavr", "espressif8266_stage"]) + ["atmelavr", "espressif8266"]) validate_cliresult(result) assert len(isolated_pio_home.join("platforms").listdir()) == 0 From 200cbae177909807c121b2ebaf9688540d6cc3a6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 26 Nov 2017 18:51:08 +0200 Subject: [PATCH 115/211] Experimental support for parsing source file in pair with a header when they have the same name // Issue #1175 --- platformio/builder/tools/piolib.py | 14 +++++++++++++- platformio/builder/tools/platformio.py | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index f0b86794..ca1a2bb9 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -334,8 +334,20 @@ class LibBuilderBase(object): sys.stderr.write( "Warning! Classic Pre Processor is used for `%s`, " "advanced has failed with `%s`\n" % (path, e)) - incs = self.env.File(path).get_found_includes( + _incs = self.env.File(path).get_found_includes( self.env, LibBuilderBase.CLASSIC_SCANNER, tuple(inc_dirs)) + incs = [] + for inc in _incs: + incs.append(inc) + _h_path = inc.get_abspath() + if not self.env.IsFileWithExt(_h_path, + piotool.SRC_HEADER_EXT): + continue + _f_part = _h_path[:_h_path.rindex(".")] + for ext in piotool.SRC_C_EXT: + if isfile("%s.%s" % (_f_part, ext)): + incs.append( + self.env.File("%s.%s" % (_f_part, ext))) # print path, map(lambda n: n.get_abspath(), incs) for inc in incs: if inc not in result: diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 67b1d43f..5d905b0a 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -27,8 +27,9 @@ from SCons.Util import case_sensitive_suffixes, is_Sequence from platformio.util import glob_escape, pioversion_to_intstr -SRC_BUILD_EXT = ["c", "cc", "cpp", "S", "spp", "SPP", "sx", "s", "asm", "ASM"] SRC_HEADER_EXT = ["h", "hpp"] +SRC_C_EXT = ["c", "cc", "cpp"] +SRC_BUILD_EXT = SRC_C_EXT + ["S", "spp", "SPP", "sx", "s", "asm", "ASM"] SRC_FILTER_DEFAULT = ["+<*>", "-<.git%s>" % sep, "-" % sep] From 46acad952e588f3a17e90aef86f6fbe96fe4bab0 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 26 Nov 2017 20:17:38 +0200 Subject: [PATCH 116/211] Parse source files by header name in default LDF mode // Issue #1175 --- platformio/builder/tools/piolib.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index ca1a2bb9..c60e357a 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -88,7 +88,9 @@ class LibBuilderBase(object): CLASSIC_SCANNER = SCons.Scanner.C.CScanner() ADVANCED_SCANNER = SCons.Scanner.C.CScanner(advanced=True) - INC_DIRS_CACHE = None + PARSE_SRC_BY_H_NAME = True + _INC_DIRS_CACHE = None + def __init__(self, env, path, manifest=None, verbose=False): self.env = env.Clone() @@ -313,15 +315,15 @@ class LibBuilderBase(object): def _get_found_includes(self, search_paths=None): # all include directories - if not LibBuilderBase.INC_DIRS_CACHE: - LibBuilderBase.INC_DIRS_CACHE = [] + if not LibBuilderBase._INC_DIRS_CACHE: + LibBuilderBase._INC_DIRS_CACHE = [] for lb in self.env.GetLibBuilders(): - LibBuilderBase.INC_DIRS_CACHE.extend( + LibBuilderBase._INC_DIRS_CACHE.extend( [self.env.Dir(d) for d in lb.get_inc_dirs()]) # append self include directories inc_dirs = [self.env.Dir(d) for d in self.get_inc_dirs()] - inc_dirs.extend(LibBuilderBase.INC_DIRS_CACHE) + inc_dirs.extend(LibBuilderBase._INC_DIRS_CACHE) result = [] for path in self._validate_search_paths(search_paths): @@ -339,6 +341,8 @@ class LibBuilderBase(object): incs = [] for inc in _incs: incs.append(inc) + if not self.PARSE_SRC_BY_H_NAME: + continue _h_path = inc.get_abspath() if not self.env.IsFileWithExt(_h_path, piotool.SRC_HEADER_EXT): @@ -374,7 +378,7 @@ class LibBuilderBase(object): self._circular_deps.append(lb) elif lb not in self._depbuilders: self._depbuilders.append(lb) - LibBuilderBase.INC_DIRS_CACHE = None + LibBuilderBase._INC_DIRS_CACHE = None lb.search_deps_recursive(search_paths) def search_deps_recursive(self, search_paths=None): From bab8ad088e4e8e0d3e3ec672823debf72d297913 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 27 Nov 2017 00:01:24 +0200 Subject: [PATCH 117/211] Parse library source file in pair with a header when they have the same name // Resolve #1175 --- HISTORY.rst | 18 ++++++++++++------ docs | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 6a9b1305..61d643c1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -9,13 +9,19 @@ PlatformIO 3.0 * PIO Home * Integration with `Jenkins CI `_ -* Depend on development platform using VSC URL (Git, Mercurial and Subversion) +* Allowed to depend on development platform using VSC URL (Git, Mercurial and Subversion) in `Project Configuration File "platformio.ini" `__ -* Improved handling of library dependencies defined as VCS or SemVer in - `Project Configuration File "platformio.ini" `__ - (`issue #1155 `_) -* Added option to configure library `Compatible Mode `__ - using `library.json `__ + Dropped support for ``*_stage`` dev/platforms. Use VCS URL instead. +* Improvements to `Library Dependency Finder (LDF) `__: + + - Parse library source file in pair with a header when they have the same name + (`issue #1175 `_) + - Handle library dependencies defined as VCS or SemVer in + `Project Configuration File "platformio.ini" `__ + (`issue #1155 `_) + - Added option to configure library `Compatible Mode `__ + using `library.json `__ + * Fixed "Super-Quick (Mac / Linux)" installer script (`issue #1017 `_) * Fixed issue with "IOError" in VSCode when processing a project diff --git a/docs b/docs index d14eee32..b7dfe7b6 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit d14eee32547ea30237c32df43aa72987245158d3 +Subproject commit b7dfe7b6fab87833ef2eb2b09181b395595eba75 From 7ec90ac23b7c289652b60a4825a31b4475198d77 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 27 Nov 2017 00:20:31 +0200 Subject: [PATCH 118/211] Bump version to 3.5.0rc1 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 9652e206..1d860e98 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0b6") +VERSION = (3, 5, "0rc1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 32c92eec950fc873e2d73eb00106c195a5d3952b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 27 Nov 2017 01:32:36 +0200 Subject: [PATCH 119/211] Add link to LDF docs --- platformio/builder/tools/piolib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index c60e357a..86f2b5d8 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -770,7 +770,7 @@ def BuildProjectLibraries(env): correct_found_libs() if project.depbuilders: - print "Library Dependency Graph" + print "Library Dependency Graph ( http://bit.ly/configure-pio-ldf )" print_deps_tree(project) else: print "No dependencies" From 79b7974f35954c629745b4bcff46e935d2140b07 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 27 Nov 2017 14:05:04 +0200 Subject: [PATCH 120/211] Strip SHA1 sum because @bintray returns wrong value --- tests/test_pkgmanifest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pkgmanifest.py b/tests/test_pkgmanifest.py index a34d6864..b7a73061 100644 --- a/tests/test_pkgmanifest.py +++ b/tests/test_pkgmanifest.py @@ -41,4 +41,4 @@ def test_packages(): if "X-Checksum-Sha1" not in r.headers: return pytest.skip("X-Checksum-Sha1 is not provided") - assert item['sha1'] == r.headers.get("X-Checksum-Sha1"), item + assert item['sha1'] == r.headers.get("X-Checksum-Sha1")[0:40], item From f5f3cd85d84c81a14015317deddac25183b6cd3f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 27 Nov 2017 21:04:51 +0200 Subject: [PATCH 121/211] Add support for Git scp-like syntax --- docs | 2 +- platformio/builder/tools/piolib.py | 1 - platformio/managers/package.py | 10 ++++------ platformio/managers/platform.py | 8 ++++---- platformio/vcsclient.py | 3 ++- tests/test_managers.py | 20 ++++++++++++-------- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/docs b/docs index b7dfe7b6..832bf5d8 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit b7dfe7b6fab87833ef2eb2b09181b395595eba75 +Subproject commit 832bf5d8a66d3ec143344578e6351d173d7e3f0b diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 86f2b5d8..be8cf6e6 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -91,7 +91,6 @@ class LibBuilderBase(object): PARSE_SRC_BY_H_NAME = True _INC_DIRS_CACHE = None - def __init__(self, env, path, manifest=None, verbose=False): self.env = env.Clone() self.envorigin = env.Clone() diff --git a/platformio/managers/package.py b/platformio/managers/package.py index a7670109..c70cc174 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -497,7 +497,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): # Parse requirements req_conditions = [ - "@" in text, not requirements, "://" not in text + "@" in text, not requirements, ":" not in text or text.rfind("/") < text.rfind("@") ] if all(req_conditions): @@ -519,9 +519,8 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): # Handle GitHub URL (https://github.com/user/package) text.startswith("https://github.com/") and not text.endswith( (".zip", ".tar.gz")), - text.startswith("http") - and (text.split("#", 1)[0] - if "#" in text else text).endswith(".git") + (text.split("#", 1)[0] + if "#" in text else text).endswith(".git") ] hg_conditions = [ # Handle Developer Mbed URL @@ -536,9 +535,8 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): url = "file://" + text elif "://" in text: url = text - # Handle short version of GitHub URL - if text.count("/") == 1: + elif text.count("/") == 1: url = "git+https://github.com/" + text # Parse name from URL diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index a3d21d01..30093ed8 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -261,7 +261,7 @@ class PlatformPackagesMixin(object): continue elif (name in with_packages or not (skip_default_package or opts.get("optional", False))): - if "://" in version: + if ":" in version: self.pm.install("%s=%s" % (name, version), silent=silent) else: self.pm.install(name, version, silent=silent) @@ -288,7 +288,7 @@ class PlatformPackagesMixin(object): def update_packages(self, only_check=False): for name, manifest in self.get_installed_packages().items(): requirements = self.packages[name].get("version", "") - if "://" in requirements: + if ":" in requirements: _, requirements, __ = self.pm.parse_pkg_uri(requirements) self.pm.update(manifest['__pkg_dir'], requirements, only_check) @@ -303,7 +303,7 @@ class PlatformPackagesMixin(object): def are_outdated_packages(self): for name, manifest in self.get_installed_packages().items(): requirements = self.packages[name].get("version", "") - if "://" in requirements: + if ":" in requirements: _, requirements, __ = self.pm.parse_pkg_uri(requirements) if self.pm.outdated(manifest['__pkg_dir'], requirements): return True @@ -311,7 +311,7 @@ class PlatformPackagesMixin(object): def get_package_dir(self, name): version = self.packages[name].get("version", "") - if "://" in version: + if ":" in version: return self.pm.get_package_dir(*self.pm.parse_pkg_uri( "%s=%s" % (name, version))) return self.pm.get_package_dir(name, version) diff --git a/platformio/vcsclient.py b/platformio/vcsclient.py index b7c72ea1..e6ad7770 100644 --- a/platformio/vcsclient.py +++ b/platformio/vcsclient.py @@ -29,8 +29,9 @@ class VCSClientFactory(object): result = urlparse(remote_url) type_ = result.scheme tag = None - if not type_ and remote_url.startswith("git@"): + if not type_ and remote_url.startswith("git+"): type_ = "git" + remote_url = remote_url[4:] elif "+" in result.scheme: type_, _ = result.scheme.split("+", 1) remote_url = remote_url[len(type_) + 1:] diff --git a/tests/test_managers.py b/tests/test_managers.py index b680b771..74bd652f 100644 --- a/tests/test_managers.py +++ b/tests/test_managers.py @@ -115,14 +115,18 @@ def test_pkg_input_parser(): "hg+https://example.com/user/package", ("package", None, "hg+https://example.com/user/package") ], - # [ - # "git@github.com:user/package.git", - # ("package", None, "git@github.com:user/package.git") - # ], - # [ - # "git@github.com:user/package.git#v1.2.0", - # ("package", None, "git@github.com:user/package.git#v1.2.0") - # ], + [ + "git@github.com:user/package.git", + ("package", None, "git+git@github.com:user/package.git") + ], + [ + "git@github.com:user/package.git#v1.2.0", + ("package", None, "git+git@github.com:user/package.git#v1.2.0") + ], + [ + "LocalName=git@github.com:user/package.git#v1.2.0@~1.2.0", + ("LocalName", "~1.2.0", "git+git@github.com:user/package.git#v1.2.0") + ], [ "git+ssh://git@gitlab.private-server.com/user/package#1.2.0", ("package", None, From 1b0776167c9dda9d5d30437a101ff0c6b138fafb Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 27 Nov 2017 21:05:40 +0200 Subject: [PATCH 122/211] Bump version to 3.5.0rc2 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 1d860e98..e678ba94 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc1") +VERSION = (3, 5, "0rc2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 3c6bd9824e50394b6f2cce73f1b85184a9d591bc Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 29 Nov 2017 15:32:38 +0200 Subject: [PATCH 123/211] Handle old "espressif" platform name for LDF --- platformio/builder/tools/piolib.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index be8cf6e6..14195581 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -218,15 +218,14 @@ class LibBuilderBase(object): return LibBuilderBase.COMPAT_MODE_DEFAULT @staticmethod - def items_in_list(items, ilist): + def items_to_list(items): + if not isinstance(items, list): + items = [i.strip() for i in items.split(",")] + return [i.lower() for i in items if i] - def _items_to_list(items_): - if not isinstance(items_, list): - items_ = [i.strip() for i in items_.split(",")] - return [i.lower() for i in items_ if i] - - items = _items_to_list(items) - ilist = _items_to_list(ilist) + def items_in_list(self, items, ilist): + items = self.items_to_list(items) + ilist = self.items_to_list(ilist) if "*" in items or "*" in ilist: return True return set(items) & set(ilist) @@ -511,6 +510,17 @@ class PlatformIOLibBuilder(LibBuilderBase): assert isfile(join(self.path, "library.json")) manifest = util.load_json(join(self.path, "library.json")) assert "name" in manifest + + # replace "espressif" dev/platform with ESP8266/ESP32 + if "platforms" in manifest: + new_platforms = [] + for platform in self.items_to_list(manifest['platforms']): + if platform == "espressif": + new_platforms.extend(["espressif8266", "espressif32"]) + else: + new_platforms.append(platform) + manifest['platforms'] = new_platforms + return manifest def _is_arduino_manifest(self): From 8f97181ea7dbf3ae5d31b7060f5a371d4f0ecb1c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 29 Nov 2017 16:07:11 +0200 Subject: [PATCH 124/211] Add "__GNUC__" macro by default for VSCode https://github.com/platformio/platformio-vscode-ide/issues/54 --- platformio/builder/tools/pioide.py | 4 +++- platformio/builder/tools/piomisc.py | 7 ++++++- .../ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/platformio/builder/tools/pioide.py b/platformio/builder/tools/pioide.py index da40bef9..99aeda42 100644 --- a/platformio/builder/tools/pioide.py +++ b/platformio/builder/tools/pioide.py @@ -91,7 +91,9 @@ def DumpIDEData(env): "gdb_path": util.where_is_program(env.subst("$GDB"), env.subst("${ENV['PATH']}")), "prog_path": - env.subst("$PROG_PATH") + env.subst("$PROG_PATH"), + "compiler_type": + env.GetCompilerType() } env_ = env.Clone() diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 98c28590..49136a1d 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -199,7 +199,8 @@ def _delete_file(path): pass -def GetCompilerType(env): +@util.memoized +def _get_compiler_type(env): try: sysenv = environ.copy() sysenv['PATH'] = str(env['ENV']['PATH']) @@ -216,6 +217,10 @@ def GetCompilerType(env): return None +def GetCompilerType(env): + return _get_compiler_type(env) + + def GetActualLDScript(env): def _lookup_in_ldpath(script): diff --git a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl index ced616b7..db933c5a 100644 --- a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl +++ b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl @@ -30,7 +30,11 @@ % for define in defines: "{{!define.replace('"', '\\"')}}", % end +% if compiler_type == "gcc": + "__GNUC__" +% else: "" +% end ], "intelliSenseMode": "clang-x64" } From 5846566bbb79b0c608c7274a3763e7dff75459f2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 29 Nov 2017 16:24:47 +0200 Subject: [PATCH 125/211] Bump version to 3.5.0rc3 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index e678ba94..d39cff4b 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc2") +VERSION = (3, 5, "0rc3") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From f922fac9d9ae6422548938c0e30192de1891eef8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 29 Nov 2017 18:30:00 +0200 Subject: [PATCH 126/211] Handle `espressif` as `espressif8266` dev/platform for LDF --- platformio/builder/tools/piolib.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 14195581..1a21eebc 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -511,15 +511,12 @@ class PlatformIOLibBuilder(LibBuilderBase): manifest = util.load_json(join(self.path, "library.json")) assert "name" in manifest - # replace "espressif" dev/platform with ESP8266/ESP32 + # replace "espressif" old name dev/platform with ESP8266 if "platforms" in manifest: - new_platforms = [] - for platform in self.items_to_list(manifest['platforms']): - if platform == "espressif": - new_platforms.extend(["espressif8266", "espressif32"]) - else: - new_platforms.append(platform) - manifest['platforms'] = new_platforms + manifest['platforms'] = [ + "espressif8266" if p == "espressif" else p + for p in self.items_to_list(manifest['platforms']) + ] return manifest From 10d21595c6e9b3de6f313c6afdca6ea3d2ff6d93 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 29 Nov 2017 22:22:31 +0200 Subject: [PATCH 127/211] Fix issue when board is not specified and "idedata" target is called --- platformio/builder/tools/pioide.py | 10 +++++++--- platformio/builder/tools/pioplatform.py | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/platformio/builder/tools/pioide.py b/platformio/builder/tools/pioide.py index 99aeda42..d622c6b3 100644 --- a/platformio/builder/tools/pioide.py +++ b/platformio/builder/tools/pioide.py @@ -63,9 +63,13 @@ def dump_defines(env): # special symbol for Atmel AVR MCU if env['PIOPLATFORM'] == "atmelavr": - defines.append( - str("__AVR_%s__" % env.BoardConfig().get("build.mcu").upper() - .replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny"))) + board_mcu = env.get("BOARD_MCU") + if not board_mcu and "BOARD" in env: + board_mcu = env.BoardConfig().get("build.mcu") + if board_mcu: + defines.append( + str("__AVR_%s__" % board_mcu.upper() + .replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny"))) return defines diff --git a/platformio/builder/tools/pioplatform.py b/platformio/builder/tools/pioplatform.py index 1b7cf377..02519dbe 100644 --- a/platformio/builder/tools/pioplatform.py +++ b/platformio/builder/tools/pioplatform.py @@ -41,8 +41,9 @@ def PioPlatform(env): def BoardConfig(env, board=None): p = initPioPlatform(env['PLATFORM_MANIFEST']) try: - config = p.board_config(board if board else env['BOARD']) - except exception.UnknownBoard as e: + assert env.get("BOARD", board), "BoardConfig: Board is not defined" + config = p.board_config(board if board else env.get("BOARD")) + except (AssertionError, exception.UnknownBoard) as e: sys.stderr.write("Error: %s\n" % str(e)) env.Exit(1) return config From 4b1716e42b14e8b5acb73905b07cbc7819cc0337 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 29 Nov 2017 22:27:03 +0200 Subject: [PATCH 128/211] CI: Install PIP for macOS build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a0515311..91b9caa0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ matrix: install: - git submodule update --init --recursive + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo python -c "$(curl -fsSL https://bootstrap.pypa.io/get-pip.py)"; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip install -U tox; else pip install -U tox; fi # ChipKIT issue: install 32-bit support for GCC PIC32 From 75160bb23101a67b05f8714462ee92c247dc7d72 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 29 Nov 2017 22:46:57 +0200 Subject: [PATCH 129/211] Better handling of errors from VCS GIT --- platformio/vcsclient.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/platformio/vcsclient.py b/platformio/vcsclient.py index e6ad7770..6a924370 100644 --- a/platformio/vcsclient.py +++ b/platformio/vcsclient.py @@ -14,7 +14,7 @@ import re from os.path import join -from subprocess import check_call +from subprocess import CalledProcessError, check_call from sys import modules from urlparse import urlparse @@ -94,7 +94,12 @@ class VCSClientBase(object): args = [self.command] + args if "cwd" not in kwargs: kwargs['cwd'] = self.src_dir - return check_call(args, **kwargs) == 0 + try: + check_call(args, **kwargs) + return True + except CalledProcessError as e: + raise PlatformioException( + "VCS: Could not process command %s" % e.cmd) def get_cmd_output(self, args, **kwargs): args = [self.command] + args @@ -112,6 +117,13 @@ class GitClient(VCSClientBase): command = "git" + def check_client(self): + try: + return VCSClientBase.check_client(self) + except UserSideException: + raise UserSideException( + "Please install Git client from https://git-scm.com/downloads") + def get_branches(self): output = self.get_cmd_output(["branch"]) output = output.replace("*", "") # fix active branch From ad48b85a440dd064350e489e9fcb2c56fb057b1a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 30 Nov 2017 00:18:11 +0200 Subject: [PATCH 130/211] Fix sudo command for OSX CI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 91b9caa0..914f1194 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ matrix: install: - git submodule update --init --recursive - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo python -c "$(curl -fsSL https://bootstrap.pypa.io/get-pip.py)"; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -fsSL https://bootstrap.pypa.io/get-pip.py | sudo python; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip install -U tox; else pip install -U tox; fi # ChipKIT issue: install 32-bit support for GCC PIC32 From d0e32ebcb5285dc096f1a5b5d7dd38e7bd9072ec Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 30 Nov 2017 02:05:14 +0200 Subject: [PATCH 131/211] CI OSX: Don't upgrade system Python packages --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 914f1194..07e019a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ matrix: install: - git submodule update --init --recursive - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -fsSL https://bootstrap.pypa.io/get-pip.py | sudo python; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip install -U tox; else pip install -U tox; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip install tox; else pip install -U tox; fi # ChipKIT issue: install 32-bit support for GCC PIC32 - if [[ "$TOX_ENV" == "py27" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libc6-i386; fi From 05069f7ac638fb6da06511e0c5256fa6ea025c9a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 1 Dec 2017 20:53:39 +0200 Subject: [PATCH 132/211] Bump version to 3.5.0rc4 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index d39cff4b..dd053380 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc3") +VERSION = (3, 5, "0rc4") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 18b10a7fbf56d10f78e7588923a7ceb3a61b72ca Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 3 Dec 2017 02:15:49 +0200 Subject: [PATCH 133/211] Raise exception when try to load non-PIO project --- platformio/managers/core.py | 2 +- platformio/util.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index dcf85bd1..bf869f72 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -23,7 +23,7 @@ from platformio.managers.package import PackageManager CORE_PACKAGES = { "contrib-piohome": ">=0.3.2,<2", "pysite-pioplus": ">=0.4.2,<2", - "tool-pioplus": ">=0.10.13,<2", + "tool-pioplus": ">=0.11.0,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" } diff --git a/platformio/util.py b/platformio/util.py index b3456444..129d3752 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -331,11 +331,10 @@ def get_projectdata_dir(): def load_project_config(path=None): if not path or isdir(path): - project_dir = path or get_project_dir() - if not is_platformio_project(project_dir): - raise exception.NotPlatformIOProject(project_dir) - path = join(project_dir, "platformio.ini") - assert isfile(path) + path = join(path or get_project_dir(), "platformio.ini") + if not isfile(path): + raise exception.NotPlatformIOProject( + dirname(path) if path.endswith("platformio.ini") else path) cp = ProjectConfig() cp.read(path) return cp From e329688954da14d314d07b5980293137cd9ff276 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 3 Dec 2017 02:25:49 +0200 Subject: [PATCH 134/211] Update PIO Home to 0.4.0 // Resolve #1034 --- platformio/managers/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index bf869f72..ba2294ca 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -21,7 +21,7 @@ from platformio import __version__, exception, util from platformio.managers.package import PackageManager CORE_PACKAGES = { - "contrib-piohome": ">=0.3.2,<2", + "contrib-piohome": ">=0.4.0,<2", "pysite-pioplus": ">=0.4.2,<2", "tool-pioplus": ">=0.11.0,<2", "tool-unity": "~1.20302.1", From ea997011728d3347a53f9287fca4f280fbff1639 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 3 Dec 2017 02:29:14 +0200 Subject: [PATCH 135/211] Bump version to 3.5.0rc5 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index dd053380..fd142602 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc4") +VERSION = (3, 5, "0rc5") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 3b1fa572fab2acab4debc6dd85d0cb3085283557 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 4 Dec 2017 16:18:45 +0200 Subject: [PATCH 136/211] Handle unicode errors --- platformio/telemetry.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 671fe20c..75fa307f 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -320,7 +320,10 @@ def on_exception(e): exception.NotPlatformIOProject, exception.UserSideException) ] - skip_conditions.append("[API] Account: " in str(e)) + try: + skip_conditions.append("[API] Account: " in str(e)) + except UnicodeEncodeError as ue: + e = ue if any(skip_conditions): return is_crash = any([ From 0394e43ba40c8ee260a04e8d2c1dd1c4cc493b3e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 12 Dec 2017 21:35:48 +0200 Subject: [PATCH 137/211] Remove caching from TravisCI template --- docs | 2 +- platformio/commands/init.py | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/docs b/docs index 832bf5d8..81346afb 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 832bf5d8a66d3ec143344578e6351d173d7e3f0b +Subproject commit 81346afbf88df746faf12e7dfcc4ee4504ab8829 diff --git a/platformio/commands/init.py b/platformio/commands/init.py index ac16bb7e..7cfc0672 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -231,11 +231,6 @@ def init_ci_conf(project_dir): # python: # - "2.7" # -# sudo: false -# cache: -# directories: -# - "~/.platformio" -# # install: # - pip install -U platformio # @@ -251,11 +246,6 @@ def init_ci_conf(project_dir): # python: # - "2.7" # -# sudo: false -# cache: -# directories: -# - "~/.platformio" -# # env: # - PLATFORMIO_CI_SRC=path/to/test/file.c # - PLATFORMIO_CI_SRC=examples/file.ino From f9b9ed317dccb9197cc46ddd37c1715a7c220754 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Dec 2017 00:59:51 +0200 Subject: [PATCH 138/211] Export built-in GCC macros for IDEs --- platformio/builder/tools/pioide.py | 36 ++++++++++++++++--- .../vscode/.vscode/c_cpp_properties.json.tpl | 4 --- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/platformio/builder/tools/pioide.py b/platformio/builder/tools/pioide.py index d622c6b3..d344b228 100644 --- a/platformio/builder/tools/pioide.py +++ b/platformio/builder/tools/pioide.py @@ -15,6 +15,7 @@ from __future__ import absolute_import from glob import glob +from os import environ from os.path import join from SCons.Defaults import processDefines @@ -23,7 +24,7 @@ from platformio import util from platformio.managers.core import get_core_package_dir -def dump_includes(env): +def _dump_includes(env): includes = [] for item in env.get("CPPPATH", []): @@ -55,7 +56,29 @@ def dump_includes(env): return includes -def dump_defines(env): +def _get_gcc_defines(env): + items = [] + try: + sysenv = environ.copy() + sysenv['PATH'] = str(env['ENV']['PATH']) + result = util.exec_command( + "echo | %s -dM -E -" % env.subst("$CC"), env=sysenv, shell=True) + except OSError: + return items + if result['returncode'] != 0: + return items + for line in result['out'].split("\n"): + tokens = line.strip().split(" ", 2) + if not tokens or tokens[0] != "#define": + continue + if len(tokens) > 2: + items.append("%s=%s" % (tokens[1], tokens[2])) + else: + items.append(tokens[1]) + return items + + +def _dump_defines(env): defines = [] # global symbols for item in processDefines(env.get("CPPDEFINES", [])): @@ -70,6 +93,11 @@ def dump_defines(env): defines.append( str("__AVR_%s__" % board_mcu.upper() .replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny"))) + + # built-in GCC marcos + if env.GetCompilerType() == "gcc": + defines.extend(_get_gcc_defines(env)) + return defines @@ -81,9 +109,9 @@ def DumpIDEData(env): "libsource_dirs": [env.subst(l) for l in env.get("LIBSOURCE_DIRS", [])], "defines": - dump_defines(env), + _dump_defines(env), "includes": - dump_includes(env), + _dump_includes(env), "cc_flags": env.subst(LINTCCOM), "cxx_flags": diff --git a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl index db933c5a..ced616b7 100644 --- a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl +++ b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl @@ -30,11 +30,7 @@ % for define in defines: "{{!define.replace('"', '\\"')}}", % end -% if compiler_type == "gcc": - "__GNUC__" -% else: "" -% end ], "intelliSenseMode": "clang-x64" } From 786dd8fe18918c8dea3c48981ec744cf77a39136 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Dec 2017 01:23:18 +0200 Subject: [PATCH 139/211] Implement "--develop" option for "upgrade" command // Resolve #104 --- docs | 2 +- platformio/commands/upgrade.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs b/docs index 81346afb..a9bc3dc0 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 81346afbf88df746faf12e7dfcc4ee4504ab8829 +Subproject commit a9bc3dc0ea0766675aaeed1aaec9527012372902 diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 9cbb6611..edff2456 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -24,12 +24,12 @@ from platformio.managers.core import update_core_packages @click.command( "upgrade", short_help="Upgrade PlatformIO to the latest version") -def cli(): +@click.option("--develop", is_flag=True, help="Force development branch") +def cli(develop): # Update PlatformIO's Core packages update_core_packages(silent=True) - latest = get_latest_version() - if __version__ == latest: + if not develop and __version__ == get_latest_version(): return click.secho( "You're up-to-date!\nPlatformIO %s is currently the " "newest version available." % __version__, @@ -40,7 +40,8 @@ def cli(): # kill all PIO Home servers, they block `pioplus` binary shutdown_servers() - to_develop = not all([c.isdigit() for c in latest if c != "."]) + to_develop = develop or not all( + [c.isdigit() for c in __version__ if c != "."]) cmds = ([ "pip", "install", "--upgrade", "https://github.com/platformio/platformio-core/archive/develop.zip" From f7815d6c9bf79c7eb9330bea44c91fc556922377 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Dec 2017 01:31:41 +0200 Subject: [PATCH 140/211] Check PIO Core updates after reset of time counter // Issue #1126 --- platformio/maintenance.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio/maintenance.py b/platformio/maintenance.py index db68423b..51fe0c6c 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -237,12 +237,12 @@ def check_platformio_upgrade(): if (time() - interval) < last_check.get("platformio_upgrade", 0): return - # Update PlatformIO's Core packages - update_core_packages(silent=True) - last_check['platformio_upgrade'] = int(time()) app.set_state_item("last_check", last_check) + # Update PlatformIO's Core packages + update_core_packages(silent=True) + latest_version = get_latest_version() if semantic_version.Version.coerce(util.pepver_to_semver( latest_version)) <= semantic_version.Version.coerce( From 02a263fdce5c7acf6dc12cabc5abff763fe6595e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Dec 2017 01:32:19 +0200 Subject: [PATCH 141/211] Bump version to 3.5.0rc6 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index fd142602..75c8ce30 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc5") +VERSION = (3, 5, "0rc6") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 3d0f0659ae21df1a94eb49ce1e6c5bb27b4686f6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Dec 2017 13:42:16 +0200 Subject: [PATCH 142/211] Rename `--develop` to `--dev` option for upgrade command --- docs | 2 +- platformio/commands/upgrade.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs b/docs index a9bc3dc0..5e303c13 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit a9bc3dc0ea0766675aaeed1aaec9527012372902 +Subproject commit 5e303c13b78db4f1a4008f3901a2d503f7db5354 diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index edff2456..57615826 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -24,12 +24,12 @@ from platformio.managers.core import update_core_packages @click.command( "upgrade", short_help="Upgrade PlatformIO to the latest version") -@click.option("--develop", is_flag=True, help="Force development branch") -def cli(develop): +@click.option("--dev", is_flag=True, help="Use development branch") +def cli(dev): # Update PlatformIO's Core packages update_core_packages(silent=True) - if not develop and __version__ == get_latest_version(): + if not dev and __version__ == get_latest_version(): return click.secho( "You're up-to-date!\nPlatformIO %s is currently the " "newest version available." % __version__, @@ -40,7 +40,7 @@ def cli(develop): # kill all PIO Home servers, they block `pioplus` binary shutdown_servers() - to_develop = develop or not all( + to_develop = dev or not all( [c.isdigit() for c in __version__ if c != "."]) cmds = ([ "pip", "install", "--upgrade", From 0f37e15b6c17b66ac9ed7053174a8f5a47ba9a83 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Dec 2017 18:14:01 +0200 Subject: [PATCH 143/211] Improve off-line mode // Resolve #1126 --- platformio/commands/upgrade.py | 3 +-- platformio/maintenance.py | 7 ++++++- platformio/util.py | 28 +++++++++++++++++++++++----- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 57615826..80e22bb1 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -40,8 +40,7 @@ def cli(dev): # kill all PIO Home servers, they block `pioplus` binary shutdown_servers() - to_develop = dev or not all( - [c.isdigit() for c in __version__ if c != "."]) + to_develop = dev or not all([c.isdigit() for c in __version__ if c != "."]) cmds = ([ "pip", "install", "--upgrade", "https://github.com/platformio/platformio-core/archive/develop.zip" diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 51fe0c6c..abbd7ca2 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -52,7 +52,8 @@ def on_platformio_end(ctx, result): # pylint: disable=W0613 check_platformio_upgrade() check_internal_updates(ctx, "platforms") check_internal_updates(ctx, "libraries") - except (exception.GetLatestVersionError, exception.APIRequestError): + except (exception.InternetIsOffline, exception.GetLatestVersionError, + exception.APIRequestError): click.secho( "Failed to check for PlatformIO upgrades. " "Please check your Internet connection.", @@ -240,6 +241,8 @@ def check_platformio_upgrade(): last_check['platformio_upgrade'] = int(time()) app.set_state_item("last_check", last_check) + util.internet_on(raise_exception=True) + # Update PlatformIO's Core packages update_core_packages(silent=True) @@ -285,6 +288,8 @@ def check_internal_updates(ctx, what): last_check[what + '_update'] = int(time()) app.set_state_item("last_check", last_check) + util.internet_on(raise_exception=True) + pm = PlatformManager() if what == "platforms" else LibraryManager() outdated_items = [] for manifest in pm.get_installed(): diff --git a/platformio/util.py b/platformio/util.py index 129d3752..80cd1858 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -18,6 +18,7 @@ import json import os import platform import re +import socket import stat import subprocess import sys @@ -540,6 +541,7 @@ def _get_api_result( def get_api_result(url, params=None, data=None, auth=None, cache_valid=None): + internet_on(raise_exception=True) from platformio.app import ContentCache total = 0 max_retries = 5 @@ -559,8 +561,6 @@ def get_api_result(url, params=None, data=None, auth=None, cache_valid=None): return result except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as e: - if not internet_on(): - raise exception.InternetIsOffline() from platformio.maintenance import in_silence total += 1 if not in_silence(): @@ -575,16 +575,34 @@ def get_api_result(url, params=None, data=None, auth=None, cache_valid=None): "Please try later.") -def internet_on(): - for url in ("http://dl.bintray.com", "http://dl.platformio.org"): +@memoized +def _internet_on(): + ips = [ + "193.222.52.25", # dl.platformio.org + "159.122.18.156" # dl.bintray.com + ] + timeout = 2 + socket.setdefaulttimeout(timeout) + for ip in ips: try: - requests.get(url, timeout=3) + if os.getenv("HTTP_PROXY", os.getenv("HTTPS_PROXY")): + requests.get("http://%s" % ip, timeout=timeout) + else: + socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((ip, + 80)) return True except: # pylint: disable=bare-except pass return False +def internet_on(raise_exception=False): + result = _internet_on() + if raise_exception and not result: + raise exception.InternetIsOffline() + return result + + def get_pythonexe_path(): return os.environ.get("PYTHONEXEPATH", normpath(sys.executable)) From 2d0ac1a9c2ed1ec3a8c7dccdcc5f22846fa6e67b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Dec 2017 20:05:39 +0200 Subject: [PATCH 144/211] Export PYTHONPATH to PIO Core+ --- platformio/managers/core.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index ba2294ca..7240100d 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -99,10 +99,11 @@ def pioplus_call(args, **kwargs): pioplus_path = join(get_core_package_dir("tool-pioplus"), "pioplus") 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['PYTHONPATH'] = (os.pathsep).join(sys.path) + os.environ['PATH'] = (os.pathsep).join( + [dirname(pythonexe_path), os.environ['PATH']]) util.copy_pythonpath_to_osenv() code = subprocess.call([pioplus_path] + args, **kwargs) From 5c4b5c2270df402a068e1edeb260de3325cd6917 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Dec 2017 22:15:37 +0200 Subject: [PATCH 145/211] Don't export PIO Core Python's PATH --- platformio/managers/core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index 7240100d..3a383ec8 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -101,7 +101,6 @@ def pioplus_call(args, **kwargs): pythonexe_path = util.get_pythonexe_path() os.environ['PYTHONEXEPATH'] = pythonexe_path os.environ['PYTHONPYSITEDIR'] = get_core_package_dir("pysite-pioplus") - os.environ['PYTHONPATH'] = (os.pathsep).join(sys.path) os.environ['PATH'] = (os.pathsep).join( [dirname(pythonexe_path), os.environ['PATH']]) util.copy_pythonpath_to_osenv() From 2522d19453c2862607d820b6a4b45f68955f5302 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Dec 2017 14:55:04 +0200 Subject: [PATCH 146/211] Fix issue when API cache is turned off --- platformio/app.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/platformio/app.py b/platformio/app.py index b4e62452..676d2d3b 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -134,16 +134,10 @@ class ContentCache(object): self._db_path = None self._lockfile = None - if not get_setting("enable_cache"): - return - self.cache_dir = cache_dir or join(util.get_home_dir(), ".cache") self._db_path = join(self.cache_dir, "db.data") def __enter__(self): - if not self._db_path or not isfile(self._db_path): - return self - self.delete() return self @@ -192,6 +186,8 @@ class ContentCache(object): return data def set(self, key, data, valid): + if not get_setting("enable_cache"): + return cache_path = self.get_cache_path(key) if isfile(cache_path): self.delete(key) @@ -220,6 +216,8 @@ class ContentCache(object): def delete(self, keys=None): """ Keys=None, delete expired items """ + if not isfile(self._db_path): + return if not keys: keys = [] if not isinstance(keys, list): From bd611bbee81a85bdbd0bb6e60534b3a346019b7b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Dec 2017 16:52:13 +0200 Subject: [PATCH 147/211] Allow to change default projects location // Resolve #1161 --- docs | 2 +- platformio/app.py | 55 ++++++++++++++++++++++--------------- platformio/managers/core.py | 2 +- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/docs b/docs index 5e303c13..0f72050d 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 5e303c13b78db4f1a4008f3901a2d503f7db5354 +Subproject commit 0f72050d3a2d9d67bfa74e426bd9418ad82fbd7f diff --git a/platformio/app.py b/platformio/app.py index 676d2d3b..ffacb7c2 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -18,7 +18,7 @@ import os import uuid from copy import deepcopy from os import environ, getenv, listdir, remove -from os.path import dirname, getmtime, isdir, isfile, join +from os.path import abspath, dirname, expanduser, getmtime, isdir, isfile, join from time import time import requests @@ -27,7 +27,25 @@ from lockfile import LockFailed, LockFile from platformio import __version__, exception, util from platformio.exception import InvalidSettingName, InvalidSettingValue + +def projects_dir_validate(projects_dir): + assert isdir(projects_dir) + return abspath(projects_dir) + + DEFAULT_SETTINGS = { + "auto_update_libraries": { + "description": "Automatically update libraries (Yes/No)", + "value": False + }, + "auto_update_platforms": { + "description": "Automatically update platforms (Yes/No)", + "value": False + }, + "check_libraries_interval": { + "description": "Check for the library updates interval (days)", + "value": 7 + }, "check_platformio_interval": { "description": "Check for the new PlatformIO interval (days)", "value": 3 @@ -36,37 +54,30 @@ DEFAULT_SETTINGS = { "description": "Check for the platform updates interval (days)", "value": 7 }, - "check_libraries_interval": { - "description": "Check for the library updates interval (days)", - "value": 7 - }, - "auto_update_platforms": { - "description": "Automatically update platforms (Yes/No)", - "value": False - }, - "auto_update_libraries": { - "description": "Automatically update libraries (Yes/No)", - "value": False - }, - "force_verbose": { - "description": "Force verbose output when processing environments", - "value": False + "enable_cache": { + "description": "Enable caching for API requests and Library Manager", + "value": True }, "enable_ssl": { "description": "Enable SSL for PlatformIO Services", "value": False }, - "enable_cache": { - "description": "Enable caching for API requests and Library Manager", - "value": True - }, "enable_telemetry": { "description": ("Telemetry service (Yes/No)"), "value": True - } + }, + "force_verbose": { + "description": "Force verbose output when processing environments", + "value": False + }, + "projects_dir": { + "description": "Default location for PlatformIO projects (PIO Home)", + "value": join(expanduser("~"), "Documents", "PlatformIO", "Projects"), + "validator": projects_dir_validate + }, } SESSION_VARS = {"command_ctx": None, "force_option": False, "caller_id": None} @@ -269,7 +280,7 @@ def sanitize_setting(name, value): defdata = DEFAULT_SETTINGS[name] try: if "validator" in defdata: - value = defdata['validator']() + value = defdata['validator'](value) elif isinstance(defdata['value'], bool): if not isinstance(value, bool): value = str(value).lower() in ("true", "yes", "y", "1") diff --git a/platformio/managers/core.py b/platformio/managers/core.py index 3a383ec8..f6ff4bff 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -23,7 +23,7 @@ from platformio.managers.package import PackageManager CORE_PACKAGES = { "contrib-piohome": ">=0.4.0,<2", "pysite-pioplus": ">=0.4.2,<2", - "tool-pioplus": ">=0.11.0,<2", + "tool-pioplus": ">=0.12.0,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" } From bc0d1f06e097e6d8a77d9a40ec849352ddf9bd34 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Dec 2017 16:52:44 +0200 Subject: [PATCH 148/211] Ensure that PIO Home works without Internet connection // Resolve #1179 --- platformio/managers/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index f6ff4bff..d3f3a98b 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -21,7 +21,7 @@ from platformio import __version__, exception, util from platformio.managers.package import PackageManager CORE_PACKAGES = { - "contrib-piohome": ">=0.4.0,<2", + "contrib-piohome": ">=0.5.3,<2", "pysite-pioplus": ">=0.4.2,<2", "tool-pioplus": ">=0.12.0,<2", "tool-unity": "~1.20302.1", From 15bb626e7841ba7b663adf8b0422903845074282 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Dec 2017 18:26:45 +0200 Subject: [PATCH 149/211] Docs: explain about VSCode known issue: "PackageManager is unable to install tool" --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 0f72050d..157c1c93 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 0f72050d3a2d9d67bfa74e426bd9418ad82fbd7f +Subproject commit 157c1c930088cd3e90451e05529946dbf720ead7 From a632583f89ca9fa7847836ee8a748da86a7abb15 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Dec 2017 20:05:06 +0200 Subject: [PATCH 150/211] Catch IOError for VSCode Terminal --- platformio/downloader.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/platformio/downloader.py b/platformio/downloader.py index d7f3ed47..7ecdbde6 100644 --- a/platformio/downloader.py +++ b/platformio/downloader.py @@ -73,19 +73,29 @@ class FileDownloader(object): def start(self): itercontent = self._request.iter_content(chunk_size=self.CHUNK_SIZE) f = open(self._destination, "wb") - - if app.is_disabled_progressbar() or self.get_size() == -1: - click.echo("Downloading...") - for chunk in itercontent: - if chunk: - f.write(chunk) - else: - chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE))) - with click.progressbar(length=chunks, label="Downloading") as pb: - for _ in pb: - f.write(next(itercontent)) - f.close() - self._request.close() + try: + if app.is_disabled_progressbar() or self.get_size() == -1: + click.echo("Downloading...") + for chunk in itercontent: + if chunk: + f.write(chunk) + else: + chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE))) + with click.progressbar( + length=chunks, label="Downloading") as pb: + for _ in pb: + f.write(next(itercontent)) + except IOError as e: + click.secho( + "IOError: Please read -> http://docs.platformio.org" + "/en/latest/ide/vscode.html" + "#packagemanager-is-unable-to-install-tool", + fg="red", + err=True) + raise e + finally: + f.close() + self._request.close() if self.get_lmtime(): self._preserve_filemtime(self.get_lmtime()) From 70b63d8618b855d6fedc080b0d9b195c96176db9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Dec 2017 20:05:50 +0200 Subject: [PATCH 151/211] Bump version to 3.5.0rc7 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 75c8ce30..db21d1b9 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc6") +VERSION = (3, 5, "0rc7") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From ef00ecd7f1aed7ccd555b841cf5b7ec36c1a0e81 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Dec 2017 20:18:19 +0200 Subject: [PATCH 152/211] Test IPs which used for testing internet connection --- platformio/util.py | 12 +++++++----- tests/test_misc.py | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 tests/test_misc.py diff --git a/platformio/util.py b/platformio/util.py index 80cd1858..cb78642e 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -575,15 +575,17 @@ def get_api_result(url, params=None, data=None, auth=None, cache_valid=None): "Please try later.") +PING_INTERNET_IPS = [ + "159.122.18.156", # dl.bintray.com + "193.222.52.25" # dl.platformio.org +] + + @memoized def _internet_on(): - ips = [ - "193.222.52.25", # dl.platformio.org - "159.122.18.156" # dl.bintray.com - ] timeout = 2 socket.setdefaulttimeout(timeout) - for ip in ips: + for ip in PING_INTERNET_IPS: try: if os.getenv("HTTP_PROXY", os.getenv("HTTPS_PROXY")): requests.get("http://%s" % ip, timeout=timeout) diff --git a/tests/test_misc.py b/tests/test_misc.py new file mode 100644 index 00000000..271a4858 --- /dev/null +++ b/tests/test_misc.py @@ -0,0 +1,21 @@ +# Copyright (c) 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import requests +from platformio import util + + +def test_ping_internet_ips(): + for ip in util.PING_INTERNET_IPS: + requests.get("http://%s" % ip, timeout=2) \ No newline at end of file From 736c6a9a1e43e8292de1dddcd0bc0c2b5c027dd3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Dec 2017 21:20:08 +0200 Subject: [PATCH 153/211] Sort all package versions using SemVer rules --- platformio/managers/package.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index c70cc174..509d9463 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -121,8 +121,9 @@ class PkgRepoMixin(object): def get_all_repo_versions(self, name): result = [] for versions in PackageRepoIterator(name, self.repositories): - result.extend([v['version'] for v in versions]) - return sorted(set(result)) + result.extend( + [semantic_version.Version(v['version']) for v in versions]) + return [str(v) for v in sorted(result)] class PkgInstallerMixin(object): From 0bd103a46d201f7663c7ca091660d069b7e936c9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Dec 2017 22:01:59 +0200 Subject: [PATCH 154/211] YAPF --- platformio/downloader.py | 6 +++--- platformio/telemetry.py | 5 +++-- tests/test_misc.py | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/platformio/downloader.py b/platformio/downloader.py index 7ecdbde6..737b21e4 100644 --- a/platformio/downloader.py +++ b/platformio/downloader.py @@ -71,18 +71,18 @@ class FileDownloader(object): return int(self._request.headers['content-length']) def start(self): + label = "Downloading" itercontent = self._request.iter_content(chunk_size=self.CHUNK_SIZE) f = open(self._destination, "wb") try: if app.is_disabled_progressbar() or self.get_size() == -1: - click.echo("Downloading...") + click.echo("%s..." % label) for chunk in itercontent: if chunk: f.write(chunk) else: chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE))) - with click.progressbar( - length=chunks, label="Downloading") as pb: + with click.progressbar(length=chunks, label=label) as pb: for _ in pb: f.write(next(itercontent)) except IOError as e: diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 75fa307f..c34f4039 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -315,8 +315,9 @@ def on_event(category, action, label=None, value=None, screen_name=None): def on_exception(e): skip_conditions = [ isinstance(e, cls) - for cls in (IOError, exception.AbortedByUser, - exception.NotGlobalLibDir, exception.InternetIsOffline, + for cls in (IOError, exception.ReturnErrorCode, + exception.AbortedByUser, exception.NotGlobalLibDir, + exception.InternetIsOffline, exception.NotPlatformIOProject, exception.UserSideException) ] diff --git a/tests/test_misc.py b/tests/test_misc.py index 271a4858..5d569b5b 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -13,9 +13,10 @@ # limitations under the License. import requests + from platformio import util def test_ping_internet_ips(): for ip in util.PING_INTERNET_IPS: - requests.get("http://%s" % ip, timeout=2) \ No newline at end of file + requests.get("http://%s" % ip, timeout=2) From ca8bc3819fabc9fbeb6078e8042589cbc233c6c7 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Dec 2017 22:02:41 +0200 Subject: [PATCH 155/211] =?UTF-8?q?Add=20"include"=20folder=20for=20projec?= =?UTF-8?q?t=E2=80=99s=20header=20files=20//=20Resolve=20issue=20#1107?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HISTORY.rst | 3 +++ docs | 2 +- platformio/builder/main.py | 1 + platformio/builder/tools/piolib.py | 9 +++++++-- platformio/util.py | 5 +++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 61d643c1..8b6dd9ad 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -9,6 +9,9 @@ PlatformIO 3.0 * PIO Home * Integration with `Jenkins CI `_ +* Added `include `__ + folder for project's header files + (`issue #1107 `_) * Allowed to depend on development platform using VSC URL (Git, Mercurial and Subversion) in `Project Configuration File "platformio.ini" `__ Dropped support for ``*_stage`` dev/platforms. Use VCS URL instead. diff --git a/docs b/docs index 157c1c93..8e95f0d9 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 157c1c930088cd3e90451e05529946dbf720ead7 +Subproject commit 8e95f0d9893cc5022968b60a43f6f3ddc32ffc2d diff --git a/platformio/builder/main.py b/platformio/builder/main.py index e355f68d..6e073cce 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -87,6 +87,7 @@ DEFAULT_ENV_OPTIONS = dict( UNIX_TIME=int(time()), PIOHOME_DIR=util.get_home_dir(), PROJECT_DIR=util.get_project_dir(), + PROJECTINCLUDE_DIR=util.get_projectinclude_dir(), PROJECTSRC_DIR=util.get_projectsrc_dir(), PROJECTTEST_DIR=util.get_projecttest_dir(), PROJECTDATA_DIR=util.get_projectdata_dir(), diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 1a21eebc..8751499b 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -154,8 +154,8 @@ class LibBuilderBase(object): def get_inc_dirs(self): items = [self.src_dir] - if all([isdir(join(self.path, d)) for d in ("inc", "src")]): - items.append(join(self.path, "inc")) + if all([isdir(join(self.path, d)) for d in ("include", "src")]): + items.append(join(self.path, "include")) return items @property @@ -613,6 +613,11 @@ class ProjectAsLibBuilder(LibBuilderBase): def src_dir(self): return self.env.subst("$PROJECTSRC_DIR") + def get_inc_dirs(self): + inc_dirs = LibBuilderBase.get_inc_dirs(self) + inc_dirs.append(self.env.subst("$PROJECTINCLUDE_DIR")) + return inc_dirs + @property def lib_ldf_mode(self): mode = LibBuilderBase.lib_ldf_mode.fget(self) diff --git a/platformio/util.py b/platformio/util.py index cb78642e..ee295fb0 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -296,6 +296,11 @@ def get_projectsrc_dir(): return get_project_optional_dir("src_dir", join(get_project_dir(), "src")) +def get_projectinclude_dir(): + return get_project_optional_dir("include_dir", + join(get_project_dir(), "include")) + + def get_projecttest_dir(): return get_project_optional_dir("test_dir", join(get_project_dir(), "test")) From 7b6ecf4e457ba6aaa2c74f3da4e8325450fadee4 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Dec 2017 00:22:40 +0200 Subject: [PATCH 156/211] Fix broken authentication via PIO Home // Resolve #1229 Resolve #1230 Resolve #1231 --- platformio/managers/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index d3f3a98b..e627239a 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -23,7 +23,7 @@ from platformio.managers.package import PackageManager CORE_PACKAGES = { "contrib-piohome": ">=0.5.3,<2", "pysite-pioplus": ">=0.4.2,<2", - "tool-pioplus": ">=0.12.0,<2", + "tool-pioplus": ">=0.12.1,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" } From 75774ad9fa647323787476ee9ba0e4c7cf119a4f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Dec 2017 01:39:10 +0200 Subject: [PATCH 157/211] Compress exception report --- platformio/telemetry.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/platformio/telemetry.py b/platformio/telemetry.py index c34f4039..6feba98a 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -15,9 +15,11 @@ import atexit import platform import Queue +import re import threading from collections import deque -from os import getenv +from os import getenv, sep +from os.path import join from time import sleep, time from traceback import format_exc @@ -313,6 +315,17 @@ def on_event(category, action, label=None, value=None, screen_name=None): def on_exception(e): + + def _cleanup_description(text): + text = text.replace("Traceback (most recent call last):", "") + text = re.sub( + r'File "([^"]+)"', + lambda m: join(*m.group(1).split(sep)[-2:]), + text, + flags=re.M) + text = re.sub(r"\s+", " ", text, flags=re.M) + return text.strip() + skip_conditions = [ isinstance(e, cls) for cls in (IOError, exception.ReturnErrorCode, @@ -332,8 +345,8 @@ def on_exception(e): "Error" in e.__class__.__name__ ]) mp = MeasurementProtocol() - mp['exd'] = ("%s: %s" % (type(e).__name__, format_exc() - if is_crash else e))[:2048] + description = _cleanup_description(format_exc() if is_crash else str(e)) + mp['exd'] = ("%s: %s" % (type(e).__name__, description))[:2048] mp['exf'] = 1 if is_crash else 0 mp.send("exception") From 0eb67a7b61576721c7bcd83944228ab53441a490 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Dec 2017 02:01:03 +0200 Subject: [PATCH 158/211] Handle unknown platform when uninstall/update --- platformio/managers/platform.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 30093ed8..f12b5537 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -87,6 +87,9 @@ class PlatformManager(BasePkgManager): name, requirements, url = self.parse_pkg_uri(package, requirements) pkg_dir = self.get_package_dir(name, requirements, url) + if not pkg_dir: + raise exception.UnknownPlatform(package) + p = PlatformFactory.newPlatform(pkg_dir) BasePkgManager.uninstall(self, pkg_dir, requirements) @@ -110,6 +113,9 @@ class PlatformManager(BasePkgManager): name, requirements, url = self.parse_pkg_uri(package, requirements) pkg_dir = self.get_package_dir(name, requirements, url) + if not pkg_dir: + raise exception.UnknownPlatform(package) + p = PlatformFactory.newPlatform(pkg_dir) pkgs_before = p.get_installed_packages().keys() From 3d67535a9ea72c57780da6feb8d41036752df741 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Dec 2017 02:12:04 +0200 Subject: [PATCH 159/211] Bump version to 3.5.0rc8 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index db21d1b9..0baa233f 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc7") +VERSION = (3, 5, "0rc8") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From fd0b45afdb9efcae0921e6b60b3229f3992364c8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Dec 2017 02:42:38 +0200 Subject: [PATCH 160/211] Use short version of a link for IOError exception --- platformio/downloader.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/platformio/downloader.py b/platformio/downloader.py index 737b21e4..4dc84a83 100644 --- a/platformio/downloader.py +++ b/platformio/downloader.py @@ -87,9 +87,7 @@ class FileDownloader(object): f.write(next(itercontent)) except IOError as e: click.secho( - "IOError: Please read -> http://docs.platformio.org" - "/en/latest/ide/vscode.html" - "#packagemanager-is-unable-to-install-tool", + "Error: Please read http://bit.ly/package-manager-ioerror", fg="red", err=True) raise e From 1a7429a1ef6f62c28fa51fb85b62d8ad600a76e9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Dec 2017 13:47:44 +0200 Subject: [PATCH 161/211] Fix "get-platformio.py" script which hangs on Windows 10 // Resolve #1118 --- HISTORY.rst | 2 ++ scripts/get-platformio.py | 28 ++++++++++++---------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 8b6dd9ad..adb3d3d3 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -32,6 +32,8 @@ PlatformIO 3.0 (`issue #1061 `_) * Fixed missing toolchain include paths for project generator (`issue #1154 `_) +* Fixed "get-platformio.py" script which hangs on Windows 10 + (`issue #1118 `_) 3.4.1 (2017-08-02) ~~~~~~~~~~~~~~~~~~ diff --git a/scripts/get-platformio.py b/scripts/get-platformio.py index 6d3cbe1d..90ad5fea 100644 --- a/scripts/get-platformio.py +++ b/scripts/get-platformio.py @@ -14,6 +14,7 @@ import os import subprocess +import site import sys from platform import system from tempfile import NamedTemporaryFile @@ -26,39 +27,34 @@ def fix_winpython_pathenv(): """ Add Python & Python Scripts to the search path on Windows """ - import ctypes - from ctypes.wintypes import HWND, UINT, WPARAM, LPARAM, LPVOID try: import _winreg as winreg except ImportError: import winreg # took these lines from the native "win_add2path.py" - pythonpath = os.path.dirname(CURINTERPRETER_PATH) + pythonpath = os.path.dirname(os.path.normpath(sys.executable)) scripts = os.path.join(pythonpath, "Scripts") - if not os.path.isdir(scripts): - os.makedirs(scripts) + appdata = os.environ["APPDATA"] + if hasattr(site, "USER_SITE"): + userpath = site.USER_SITE.replace(appdata, "%APPDATA%") + userscripts = os.path.join(userpath, "Scripts") + else: + userscripts = None - with winreg.CreateKey(winreg.HKEY_CURRENT_USER, u"Environment") as key: + with winreg.CreateKey(winreg.HKEY_CURRENT_USER, "Environment") as key: try: - envpath = winreg.QueryValueEx(key, u"PATH")[0] + envpath = winreg.QueryValueEx(key, "PATH")[0] except WindowsError: envpath = u"%PATH%" paths = [envpath] - for path in (pythonpath, scripts): + for path in (pythonpath, scripts, userscripts): if path and path not in envpath and os.path.isdir(path): paths.append(path) envpath = os.pathsep.join(paths) - winreg.SetValueEx(key, u"PATH", 0, winreg.REG_EXPAND_SZ, envpath) - winreg.ExpandEnvironmentStrings(envpath) - - # notify the system about the changes - SendMessage = ctypes.windll.user32.SendMessageW - SendMessage.argtypes = HWND, UINT, WPARAM, LPVOID - SendMessage.restype = LPARAM - SendMessage(0xFFFF, 0x1A, 0, u"Environment") + winreg.SetValueEx(key, "PATH", 0, winreg.REG_EXPAND_SZ, envpath) return True From 0933e46a5863e6cba409954c6ed984d99cb75535 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Dec 2017 14:09:07 +0200 Subject: [PATCH 162/211] Update history --- HISTORY.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index adb3d3d3..aa6a3730 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -25,15 +25,15 @@ PlatformIO 3.0 - Added option to configure library `Compatible Mode `__ using `library.json `__ -* Fixed "Super-Quick (Mac / Linux)" installer script - (`issue #1017 `_) -* Fixed issue with "IOError" in VSCode when processing a project * Fixed platforms, packages, and libraries updating behind proxy (`issue #1061 `_) * Fixed missing toolchain include paths for project generator (`issue #1154 `_) +* Fixed "Super-Quick (Mac / Linux)" installation in "get-platformio.py" script + (`issue #1017 `_) * Fixed "get-platformio.py" script which hangs on Windows 10 (`issue #1118 `_) +* Other bug fixes and performance improvements 3.4.1 (2017-08-02) ~~~~~~~~~~~~~~~~~~ From bff590e2072fa373af6fa5143822159d2a87c22b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Dec 2017 21:48:20 +0200 Subject: [PATCH 163/211] Search for libraries used in test // Resolve #953 --- HISTORY.rst | 2 ++ platformio/builder/tools/piolib.py | 3 ++ platformio/builder/tools/platformio.py | 45 +++++++++++++------------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index aa6a3730..71849c69 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,6 +17,8 @@ PlatformIO 3.0 Dropped support for ``*_stage`` dev/platforms. Use VCS URL instead. * Improvements to `Library Dependency Finder (LDF) `__: + - Search for libraries used in test + (`issue #953 `_) - Parse library source file in pair with a header when they have the same name (`issue #1175 `_) - Handle library dependencies defined as VCS or SemVer in diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 8751499b..3d9b5f60 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -618,6 +618,9 @@ class ProjectAsLibBuilder(LibBuilderBase): inc_dirs.append(self.env.subst("$PROJECTINCLUDE_DIR")) return inc_dirs + def get_src_files(self): + return self.env['PIOBUILDFILES'] + @property def lib_ldf_mode(self): mode = LibBuilderBase.lib_ldf_mode.fget(self) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 5d905b0a..14361742 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -42,12 +42,28 @@ def BuildProgram(env): _append_pio_macros() - # fix ASM handling under non-casitive OS - if not case_sensitive_suffixes(".s", ".S"): - env.Replace(AS="$CC", ASCOM="$ASPPCOM") + env.Append( + LIBPATH=["$BUILD_DIR"], + PIOBUILDFILES=env.CollectBuildFiles( + "$BUILDSRC_DIR", + "$PROJECTSRC_DIR", + src_filter=env.get("SRC_FILTER"), + duplicate=False)) if "__debug" in COMMAND_LINE_TARGETS: env.ProcessDebug() + if "__test" in COMMAND_LINE_TARGETS: + env.Append(PIOBUILDFILES=env.ProcessTest()) + + if not env['PIOBUILDFILES'] and not COMMAND_LINE_TARGETS: + sys.stderr.write( + "Error: Nothing to build. Please put your source code files " + "to '%s' folder\n" % env.subst("$PROJECTSRC_DIR")) + env.Exit(1) + + # fix ASM handling under non-casitive OS + if not case_sensitive_suffixes(".s", ".S"): + env.Replace(AS="$CC", ASCOM="$ASPPCOM") # process extra flags from board if "BOARD" in env and "build.extra_flags" in env.BoardConfig(): @@ -57,13 +73,14 @@ def BuildProgram(env): # apply user flags env.ProcessFlags(env.get("BUILD_FLAGS")) + # process framework scripts env.BuildFrameworks(env.get("PIOFRAMEWORK")) # restore PIO macros if it was deleted by framework _append_pio_macros() # build dependent libs - deplibs = env.BuildProjectLibraries() + env.Append(LIBS=env.BuildProjectLibraries()) # append specified LD_SCRIPT if ("LDSCRIPT_PATH" in env @@ -71,31 +88,13 @@ def BuildProgram(env): env.Append(LINKFLAGS=['-Wl,-T"$LDSCRIPT_PATH"']) # enable "cyclic reference" for linker - if env.get("LIBS", deplibs) and env.GetCompilerType() == "gcc": + if env.get("LIBS") and env.GetCompilerType() == "gcc": env.Prepend(_LIBFLAGS="-Wl,--start-group ") env.Append(_LIBFLAGS=" -Wl,--end-group") # Handle SRC_BUILD_FLAGS env.ProcessFlags(env.get("SRC_BUILD_FLAGS")) - env.Append( - LIBS=deplibs, - LIBPATH=["$BUILD_DIR"], - PIOBUILDFILES=env.CollectBuildFiles( - "$BUILDSRC_DIR", - "$PROJECTSRC_DIR", - src_filter=env.get("SRC_FILTER"), - duplicate=False)) - - if "__test" in COMMAND_LINE_TARGETS: - env.Append(PIOBUILDFILES=env.ProcessTest()) - - if not env['PIOBUILDFILES'] and not COMMAND_LINE_TARGETS: - sys.stderr.write( - "Error: Nothing to build. Please put your source code files " - "to '%s' folder\n" % env.subst("$PROJECTSRC_DIR")) - env.Exit(1) - program = env.Program( join("$BUILD_DIR", env.subst("$PROGNAME")), env['PIOBUILDFILES']) From 42fb589369fd5df4bbca654536cf9863a62fae1a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Dec 2017 22:16:37 +0200 Subject: [PATCH 164/211] Refactor PyLint "inconsistent-return-statements" --- platformio/app.py | 6 +++--- platformio/builder/tools/piolib.py | 2 +- platformio/builder/tools/piomisc.py | 2 +- platformio/builder/tools/piowinhooks.py | 2 +- platformio/commands/boards.py | 1 + platformio/commands/device.py | 10 +++++----- platformio/commands/lib.py | 12 +++++++++++- platformio/commands/platform.py | 6 +++++- platformio/commands/upgrade.py | 2 ++ platformio/managers/core.py | 9 ++++++++- platformio/managers/lib.py | 4 ++-- platformio/managers/package.py | 13 ++++++------- platformio/managers/platform.py | 2 +- platformio/telemetry.py | 1 + 14 files changed, 48 insertions(+), 24 deletions(-) diff --git a/platformio/app.py b/platformio/app.py index ffacb7c2..537ec2a3 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -198,12 +198,12 @@ class ContentCache(object): def set(self, key, data, valid): if not get_setting("enable_cache"): - return + return False cache_path = self.get_cache_path(key) if isfile(cache_path): self.delete(key) if not data: - return + return False if not isdir(self.cache_dir): os.makedirs(self.cache_dir) tdmap = {"s": 1, "m": 60, "h": 3600, "d": 86400} @@ -228,7 +228,7 @@ class ContentCache(object): def delete(self, keys=None): """ Keys=None, delete expired items """ if not isfile(self._db_path): - return + return None if not keys: keys = [] if not isinstance(keys, list): diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 3d9b5f60..9831c349 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -693,7 +693,7 @@ def GetLibBuilders(env): # pylint: disable=too-many-branches if lb.name in env.get("LIB_IGNORE", []): if verbose: sys.stderr.write("Ignored library %s\n" % lb.path) - return + return None if compat_mode > 1 and not lb.is_platforms_compatible( env['PIOPLATFORM']): if verbose: diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 49136a1d..16dae086 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -50,7 +50,7 @@ class InoToCPPConverter(object): def convert(self, nodes): contents = self.merge(nodes) if not contents: - return + return None return self.process(contents) def merge(self, nodes): diff --git a/platformio/builder/tools/piowinhooks.py b/platformio/builder/tools/piowinhooks.py index 5ac19f5d..7db4f943 100644 --- a/platformio/builder/tools/piowinhooks.py +++ b/platformio/builder/tools/piowinhooks.py @@ -72,7 +72,7 @@ def exists(_): def generate(env): if system() != "Windows": - return + return None env.Replace(_long_sources_hook=long_sources_hook) env.Replace(_long_incflags_hook=long_incflags_hook) diff --git a/platformio/commands/boards.py b/platformio/commands/boards.py index 522a8a47..e4921354 100644 --- a/platformio/commands/boards.py +++ b/platformio/commands/boards.py @@ -42,6 +42,7 @@ def cli(query, installed, json_output): # pylint: disable=R0912 click.secho(platform, bold=True) click.echo("-" * terminal_width) print_boards(boards) + return True def print_boards(boards): diff --git a/platformio/commands/device.py b/platformio/commands/device.py index 201ae474..f4094cc3 100644 --- a/platformio/commands/device.py +++ b/platformio/commands/device.py @@ -30,10 +30,8 @@ def cli(): @cli.command("list", short_help="List devices") @click.option("--json-output", is_flag=True) def device_list(json_output): - if json_output: - click.echo(json.dumps(util.get_serialports())) - return + return click.echo(json.dumps(util.get_serialports())) for item in util.get_serialports(): click.secho(item['port'], fg="cyan") @@ -42,6 +40,8 @@ def device_list(json_output): click.echo("Description: %s" % item['description']) click.echo("") + return True + @cli.command("monitor", short_help="Monitor device (Serial)") @click.option("--port", "-p", help="Port, a number or a device name") @@ -154,7 +154,7 @@ def device_monitor(**kwargs): # pylint: disable=too-many-branches def get_project_options(project_dir, environment): config = util.load_project_config(project_dir) if not config.sections(): - return + return None known_envs = [s[4:] for s in config.sections() if s.startswith("env:")] if environment: @@ -163,7 +163,7 @@ def get_project_options(project_dir, environment): raise exception.UnknownEnvNames(environment, ", ".join(known_envs)) if not known_envs: - return + return None if config.has_option("platformio", "env_default"): env_default = config.get("platformio", diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index 5a49369b..e3338816 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -143,6 +143,8 @@ def lib_update(lm, libraries, only_check, json_output): for library in libraries: lm.update(library, only_check=only_check) + return True + def print_lib_item(item): click.secho(item['name'], fg="cyan") @@ -265,11 +267,13 @@ def lib_list(lm, json_output): return click.echo(json.dumps(items)) if not items: - return + return None for item in sorted(items, key=lambda i: i['name']): print_lib_item(item) + return True + @util.memoized def get_builtin_libs(storage_names=None): @@ -308,6 +312,8 @@ def lib_builtin(storage, json_output): for item in sorted(storage_['items'], key=lambda i: i['name']): print_lib_item(item) + return True + @cli.command("show", short_help="Show detailed info about a library") @click.argument("library", metavar="[LIBRARY]") @@ -381,6 +387,8 @@ def lib_show(library, json_output): for row in rows: click.echo(row) + return True + @cli.command("register", short_help="Register a new library") @click.argument("config_url") @@ -468,3 +476,5 @@ def lib_stats(json_output): for item in result.get(key, []): _print_lib_item(item) click.echo() + + return True diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index 61584691..ff54bc9f 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -257,7 +257,7 @@ def platform_show(platform, json_output): # pylint: disable=too-many-branches click.echo("Frameworks: %s" % ", ".join(data['frameworks'])) if not data['packages']: - return + return None if not isinstance(data['packages'][0], dict): click.echo("Packages: %s" % ", ".join(data['packages'])) @@ -287,6 +287,8 @@ def platform_show(platform, json_output): # pylint: disable=too-many-branches click.echo("------") print_boards(data['boards']) + return True + @cli.command("install", short_help="Install new development platform") @click.argument("platforms", nargs=-1, required=True, metavar="[PLATFORM...]") @@ -375,3 +377,5 @@ def platform_update(platforms, only_packages, only_check, json_output): pm.update( platform, only_packages=only_packages, only_check=only_check) click.echo() + + return True diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 80e22bb1..1df215f9 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -93,6 +93,8 @@ WARNING! Don't use `sudo` for the rest PlatformIO commands. raise exception.UpgradeError("\n".join( [str(cmd), r['out'], r['err']])) + return True + def get_latest_version(): try: diff --git a/platformio/managers/core.py b/platformio/managers/core.py index e627239a..5c508498 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -42,7 +42,12 @@ class CorePackageManager(PackageManager): ("" if sys.version_info < (2, 7, 9) else "s") ]) - def install(self, name, requirements=None, *args, **kwargs): + def install( # pylint: disable=keyword-arg-before-vararg + self, + name, + requirements=None, + *args, + **kwargs): PackageManager.install(self, name, requirements, *args, **kwargs) self.cleanup_packages() return self.get_package_dir(name, requirements) @@ -126,3 +131,5 @@ def pioplus_call(args, **kwargs): if code != 0: raise exception.ReturnErrorCode(1) + + return True diff --git a/platformio/managers/lib.py b/platformio/managers/lib.py index 193cbca7..2b20768d 100644 --- a/platformio/managers/lib.py +++ b/platformio/managers/lib.py @@ -256,10 +256,10 @@ class LibraryManager(BasePkgManager): except exception.InternetIsOffline as e: if not silent: click.secho(str(e), fg="yellow") - return + return None if not pkg_dir: - return + return None manifest = self.load_manifest(pkg_dir) if "dependencies" not in manifest: diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 509d9463..dd9e5052 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -384,7 +384,7 @@ class PkgInstallerMixin(object): finally: if isdir(tmp_dir): util.rmtree_(tmp_dir) - return + return None def _update_src_manifest(self, data, src_dir): if not isdir(src_dir): @@ -603,18 +603,17 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): requirements=None, silent=False, trigger_event=True): + name, requirements, url = self.parse_pkg_uri(name, requirements) + package_dir = self.get_package_dir(name, requirements, url) # avoid circle dependencies if not self.INSTALL_HISTORY: self.INSTALL_HISTORY = [] history_key = "%s-%s" % (name, requirements) if requirements else name if history_key in self.INSTALL_HISTORY: - return + return package_dir self.INSTALL_HISTORY.append(history_key) - name, requirements, url = self.parse_pkg_uri(name, requirements) - package_dir = self.get_package_dir(name, requirements, url) - if not package_dir or not silent: msg = "Installing " + click.style(name, fg="cyan") if requirements: @@ -714,7 +713,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): nl=False) if not util.internet_on(): click.echo("[%s]" % (click.style("Off-line", fg="yellow"))) - return + return None latest = self.outdated(pkg_dir, requirements) if latest: @@ -725,7 +724,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): click.echo("[%s]" % (click.style("Fixed", fg="yellow"))) if only_check or not latest: - return + return True if "__src_url" in manifest: vcs = VCSClientFactory.newClient(pkg_dir, manifest['__src_url']) diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index f12b5537..f0baf36d 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -672,7 +672,7 @@ class PlatformBoardConfig(object): def get_debug_data(self): if not self._manifest.get("debug", {}).get("tools"): - return + return None tools = {} for name, options in self._manifest['debug']['tools'].items(): tools[name] = {} diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 6feba98a..c3fd438f 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -407,3 +407,4 @@ def resend_backuped_reports(): # clean tm['backup'] = [] app.set_state_item("telemetry", tm) + return True From 56aeff87dd0c18a55355ebfd9983c80485932b71 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Dec 2017 22:31:35 +0200 Subject: [PATCH 165/211] Typo fix --- platformio/builder/tools/platformio.py | 39 +++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 14361742..62f7d369 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -42,25 +42,6 @@ def BuildProgram(env): _append_pio_macros() - env.Append( - LIBPATH=["$BUILD_DIR"], - PIOBUILDFILES=env.CollectBuildFiles( - "$BUILDSRC_DIR", - "$PROJECTSRC_DIR", - src_filter=env.get("SRC_FILTER"), - duplicate=False)) - - if "__debug" in COMMAND_LINE_TARGETS: - env.ProcessDebug() - if "__test" in COMMAND_LINE_TARGETS: - env.Append(PIOBUILDFILES=env.ProcessTest()) - - if not env['PIOBUILDFILES'] and not COMMAND_LINE_TARGETS: - sys.stderr.write( - "Error: Nothing to build. Please put your source code files " - "to '%s' folder\n" % env.subst("$PROJECTSRC_DIR")) - env.Exit(1) - # fix ASM handling under non-casitive OS if not case_sensitive_suffixes(".s", ".S"): env.Replace(AS="$CC", ASCOM="$ASPPCOM") @@ -79,6 +60,20 @@ def BuildProgram(env): # restore PIO macros if it was deleted by framework _append_pio_macros() + # Search for project source files + env.Append( + LIBPATH=["$BUILD_DIR"], + PIOBUILDFILES=env.CollectBuildFiles( + "$BUILDSRC_DIR", + "$PROJECTSRC_DIR", + src_filter=env.get("SRC_FILTER"), + duplicate=False)) + + if "__debug" in COMMAND_LINE_TARGETS: + env.ProcessDebug() + if "__test" in COMMAND_LINE_TARGETS: + env.Append(PIOBUILDFILES=env.ProcessTest()) + # build dependent libs env.Append(LIBS=env.BuildProjectLibraries()) @@ -95,6 +90,12 @@ def BuildProgram(env): # Handle SRC_BUILD_FLAGS env.ProcessFlags(env.get("SRC_BUILD_FLAGS")) + if not env['PIOBUILDFILES'] and not COMMAND_LINE_TARGETS: + sys.stderr.write( + "Error: Nothing to build. Please put your source code files " + "to '%s' folder\n" % env.subst("$PROJECTSRC_DIR")) + env.Exit(1) + program = env.Program( join("$BUILD_DIR", env.subst("$PROGNAME")), env['PIOBUILDFILES']) From 269935726dae4660aba2826fea58b024f8700a72 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Dec 2017 23:36:23 +0200 Subject: [PATCH 166/211] Check all URL parsed args before installing a package --- platformio/managers/package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index dd9e5052..ed5efe41 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -609,7 +609,7 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): # avoid circle dependencies if not self.INSTALL_HISTORY: self.INSTALL_HISTORY = [] - history_key = "%s-%s" % (name, requirements) if requirements else name + history_key = "%s-%s-%s" % (name, requirements or "", url or "") if history_key in self.INSTALL_HISTORY: return package_dir self.INSTALL_HISTORY.append(history_key) From abbba7fe2e21080cdd2e4147635ef8cf7535213e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 15 Dec 2017 23:51:13 +0200 Subject: [PATCH 167/211] Don't use PIOBUILDFILES for LDF --- platformio/builder/tools/piolib.py | 2 +- platformio/builder/tools/platformio.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 9831c349..fdf351bb 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -619,7 +619,7 @@ class ProjectAsLibBuilder(LibBuilderBase): return inc_dirs def get_src_files(self): - return self.env['PIOBUILDFILES'] + return self.env.get("PROJECTBUILDFILES", []) @property def lib_ldf_mode(self): diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 62f7d369..adfd6209 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -63,7 +63,7 @@ def BuildProgram(env): # Search for project source files env.Append( LIBPATH=["$BUILD_DIR"], - PIOBUILDFILES=env.CollectBuildFiles( + PROJECTBUILDFILES=env.CollectBuildFiles( "$BUILDSRC_DIR", "$PROJECTSRC_DIR", src_filter=env.get("SRC_FILTER"), @@ -72,7 +72,7 @@ def BuildProgram(env): if "__debug" in COMMAND_LINE_TARGETS: env.ProcessDebug() if "__test" in COMMAND_LINE_TARGETS: - env.Append(PIOBUILDFILES=env.ProcessTest()) + env.Append(PROJECTBUILDFILES=env.ProcessTest()) # build dependent libs env.Append(LIBS=env.BuildProjectLibraries()) @@ -90,14 +90,15 @@ def BuildProgram(env): # Handle SRC_BUILD_FLAGS env.ProcessFlags(env.get("SRC_BUILD_FLAGS")) - if not env['PIOBUILDFILES'] and not COMMAND_LINE_TARGETS: + if not env.get("PROJECTBUILDFILES") and not COMMAND_LINE_TARGETS: sys.stderr.write( "Error: Nothing to build. Please put your source code files " "to '%s' folder\n" % env.subst("$PROJECTSRC_DIR")) env.Exit(1) program = env.Program( - join("$BUILD_DIR", env.subst("$PROGNAME")), env['PIOBUILDFILES']) + join("$BUILD_DIR", env.subst("$PROGNAME")), + env['PROJECTBUILDFILES'] + env.get("PIOBUILDFILES", [])) checksize_action = Action(env.CheckUploadSize, "Checking program size") AlwaysBuild(env.Alias("checkprogsize", program, checksize_action)) From 05081561c3e45efbe755e4a56b186fb7e2af19e1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Dec 2017 01:07:03 +0200 Subject: [PATCH 168/211] Minor fixes --- platformio/app.py | 1 + platformio/ide/projectgenerator.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/platformio/app.py b/platformio/app.py index 537ec2a3..44962a23 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -160,6 +160,7 @@ class ContentCache(object): os.makedirs(self.cache_dir) self._lockfile = LockFile(self.cache_dir) if self._lockfile.is_locked() and \ + isfile(self._lockfile.lock_file) and \ (time() - getmtime(self._lockfile.lock_file)) > 10: self._lockfile.break_lock() diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index 7a7ce7fb..e1d5b12a 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -59,7 +59,12 @@ class ProjectGenerator(object): @util.memoized def get_project_build_data(self): - data = {"defines": [], "includes": [], "cxx_path": None} + data = { + "defines": [], + "includes": [], + "cxx_path": None, + "prog_path": None + } envdata = self.get_project_env() if not envdata: return data From 25341d1ec7ededd8df9f4fa363e948ca7f64039a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Dec 2017 01:07:18 +0200 Subject: [PATCH 169/211] Bump version to 3.5.0rc9 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 0baa233f..12dc1830 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc8") +VERSION = (3, 5, "0rc9") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 3d8183a2e1aa2f02f0761d5b33f1c01051cd888b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Dec 2017 15:38:13 +0200 Subject: [PATCH 170/211] LDF: handle "include" folder per project; fix issue with header files // Resolve #1235 --- examples | 2 +- platformio/builder/tools/pioide.py | 2 +- platformio/builder/tools/piolib.py | 178 +++++++++++++++---------- platformio/builder/tools/piomisc.py | 3 +- platformio/builder/tools/platformio.py | 18 ++- 5 files changed, 119 insertions(+), 84 deletions(-) diff --git a/examples b/examples index 2998735e..2d716306 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 2998735ea5870291766161fae7c9ecc611a33d66 +Subproject commit 2d716306f33cbaa3d9146e417d02e15747cadb2a diff --git a/platformio/builder/tools/pioide.py b/platformio/builder/tools/pioide.py index d344b228..726d52dd 100644 --- a/platformio/builder/tools/pioide.py +++ b/platformio/builder/tools/pioide.py @@ -32,7 +32,7 @@ def _dump_includes(env): # installed libs for lb in env.GetLibBuilders(): - includes.extend(lb.get_inc_dirs()) + includes.extend(lb.get_include_dirs()) # includes from toolchains p = env.PioPlatform() diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index fdf351bb..f1f4c33c 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -24,7 +24,7 @@ from os.path import (basename, commonprefix, dirname, isdir, isfile, join, from platform import system import SCons.Scanner -from SCons.Script import ARGUMENTS, DefaultEnvironment +from SCons.Script import ARGUMENTS, COMMAND_LINE_TARGETS, DefaultEnvironment from platformio import util from platformio.builder.tools import platformio as piotool @@ -89,7 +89,7 @@ class LibBuilderBase(object): CLASSIC_SCANNER = SCons.Scanner.C.CScanner() ADVANCED_SCANNER = SCons.Scanner.C.CScanner(advanced=True) PARSE_SRC_BY_H_NAME = True - _INC_DIRS_CACHE = None + _INCLUDE_DIRS_CACHE = None def __init__(self, env, path, manifest=None, verbose=False): self.env = env.Clone() @@ -102,7 +102,7 @@ class LibBuilderBase(object): self._is_built = False self._depbuilders = list() self._circular_deps = list() - self._scanned_paths = list() + self._processed_files = list() # reset source filter, could be overridden with extra script self.env['SRC_FILTER'] = "" @@ -143,21 +143,28 @@ class LibBuilderBase(object): "-" % os.sep ] + @property + def include_dir(self): + if not all([isdir(join(self.path, d)) for d in ("include", "src")]): + return None + return join(self.path, "include") + @property def src_dir(self): return (join(self.path, "src") if isdir(join(self.path, "src")) else self.path) + def get_include_dirs(self): + items = [self.src_dir] + include_dir = self.include_dir + if include_dir and include_dir not in items: + items.append(include_dir) + return items + @property def build_dir(self): return join("$BUILD_DIR", "lib", basename(self.path)) - def get_inc_dirs(self): - items = [self.src_dir] - if all([isdir(join(self.path, d)) for d in ("include", "src")]): - items.append(join(self.path, "include")) - return items - @property def build_flags(self): return None @@ -239,13 +246,6 @@ class LibBuilderBase(object): def load_manifest(self): return {} - def get_src_files(self): - return [ - join(self.src_dir, item) - for item in self.env.MatchSourceFiles(self.src_dir, - self.src_filter) - ] - def process_extra_options(self): with util.cd(self.path): self.env.ProcessUnFlags(self.build_unflags) @@ -298,44 +298,60 @@ class LibBuilderBase(object): "library\n" % (item['name'], self.name)) self.env.Exit(1) - def _validate_search_paths(self, search_paths=None): - if not search_paths: - search_paths = [] - assert isinstance(search_paths, list) + def get_search_files(self): + items = [ + join(self.src_dir, item) + for item in self.env.MatchSourceFiles(self.src_dir, + self.src_filter) + ] + include_dir = self.include_dir + if include_dir: + items.extend([ + join(include_dir, item) + for item in self.env.MatchSourceFiles(include_dir) + ]) + return items - _search_paths = [] - for path in search_paths: - if path not in self._scanned_paths: - _search_paths.append(path) - self._scanned_paths.append(path) + def _validate_search_files(self, search_files=None): + if not search_files: + search_files = [] + assert isinstance(search_files, list) - return _search_paths + _search_files = [] + for path in search_files: + if path not in self._processed_files: + _search_files.append(path) + self._processed_files.append(path) - def _get_found_includes(self, search_paths=None): + return _search_files + + def _get_found_includes(self, search_files=None): # all include directories - if not LibBuilderBase._INC_DIRS_CACHE: - LibBuilderBase._INC_DIRS_CACHE = [] + if not LibBuilderBase._INCLUDE_DIRS_CACHE: + LibBuilderBase._INCLUDE_DIRS_CACHE = [] for lb in self.env.GetLibBuilders(): - LibBuilderBase._INC_DIRS_CACHE.extend( - [self.env.Dir(d) for d in lb.get_inc_dirs()]) + LibBuilderBase._INCLUDE_DIRS_CACHE.extend( + [self.env.Dir(d) for d in lb.get_include_dirs()]) # append self include directories - inc_dirs = [self.env.Dir(d) for d in self.get_inc_dirs()] - inc_dirs.extend(LibBuilderBase._INC_DIRS_CACHE) + include_dirs = [self.env.Dir(d) for d in self.get_include_dirs()] + include_dirs.extend(LibBuilderBase._INCLUDE_DIRS_CACHE) result = [] - for path in self._validate_search_paths(search_paths): + for path in self._validate_search_files(search_files): try: assert "+" in self.lib_ldf_mode incs = self.env.File(path).get_found_includes( - self.env, LibBuilderBase.ADVANCED_SCANNER, tuple(inc_dirs)) + self.env, LibBuilderBase.ADVANCED_SCANNER, + tuple(include_dirs)) except Exception as e: # pylint: disable=broad-except if self.verbose and "+" in self.lib_ldf_mode: sys.stderr.write( "Warning! Classic Pre Processor is used for `%s`, " "advanced has failed with `%s`\n" % (path, e)) _incs = self.env.File(path).get_found_includes( - self.env, LibBuilderBase.CLASSIC_SCANNER, tuple(inc_dirs)) + self.env, LibBuilderBase.CLASSIC_SCANNER, + tuple(include_dirs)) incs = [] for inc in _incs: incs.append(inc) @@ -356,7 +372,7 @@ class LibBuilderBase(object): result.append(inc) return result - def depend_recursive(self, lb, search_paths=None): + def depend_recursive(self, lb, search_files=None): def _already_depends(_lb): if self in _lb.depbuilders: @@ -376,23 +392,23 @@ class LibBuilderBase(object): self._circular_deps.append(lb) elif lb not in self._depbuilders: self._depbuilders.append(lb) - LibBuilderBase._INC_DIRS_CACHE = None - lb.search_deps_recursive(search_paths) + LibBuilderBase._INCLUDE_DIRS_CACHE = None + lb.search_deps_recursive(search_files) - def search_deps_recursive(self, search_paths=None): + def search_deps_recursive(self, search_files=None): if not self._is_dependent: self._is_dependent = True self.process_dependencies() if self.lib_ldf_mode.startswith("deep"): - search_paths = self.get_src_files() + search_files = self.get_search_files() # when LDF is disabled if self.lib_ldf_mode == "off": return lib_inc_map = {} - for inc in self._get_found_includes(search_paths): + for inc in self._get_found_includes(search_files): for lb in self.env.GetLibBuilders(): if inc.get_abspath() in lb: if lb not in lib_inc_map: @@ -400,8 +416,8 @@ class LibBuilderBase(object): lib_inc_map[lb].append(inc.get_abspath()) break - for lb, lb_search_paths in lib_inc_map.items(): - self.depend_recursive(lb, lb_search_paths) + for lb, lb_search_files in lib_inc_map.items(): + self.depend_recursive(lb, lb_search_files) def build(self): libs = [] @@ -412,13 +428,13 @@ class LibBuilderBase(object): self.env.AppendUnique(**{key: lb.env.get(key)}) for lb in self._circular_deps: - self.env.AppendUnique(CPPPATH=lb.get_inc_dirs()) + self.env.AppendUnique(CPPPATH=lb.get_include_dirs()) if self._is_built: return libs self._is_built = True - self.env.AppendUnique(CPPPATH=self.get_inc_dirs()) + self.env.AppendUnique(CPPPATH=self.get_include_dirs()) if self.lib_ldf_mode == "off": for lb in self.env.GetLibBuilders(): @@ -455,13 +471,13 @@ class ArduinoLibBuilder(LibBuilderBase): manifest[key.strip()] = value.strip() return manifest - def get_inc_dirs(self): - inc_dirs = LibBuilderBase.get_inc_dirs(self) + def get_include_dirs(self): + include_dirs = LibBuilderBase.get_include_dirs(self) if isdir(join(self.path, "src")): - return inc_dirs + return include_dirs if isdir(join(self.path, "utility")): - inc_dirs.append(join(self.path, "utility")) - return inc_dirs + include_dirs.append(join(self.path, "utility")) + return include_dirs @property def src_filter(self): @@ -486,19 +502,25 @@ class MbedLibBuilder(LibBuilderBase): return {} return util.load_json(join(self.path, "module.json")) + @property + def include_dir(self): + if isdir(join(self.path, "include")): + return join(self.path, "include") + return None + @property def src_dir(self): if isdir(join(self.path, "source")): return join(self.path, "source") return LibBuilderBase.src_dir.fget(self) - def get_inc_dirs(self): - inc_dirs = LibBuilderBase.get_inc_dirs(self) - if self.path not in inc_dirs: - inc_dirs.append(self.path) + def get_include_dirs(self): + include_dirs = LibBuilderBase.get_include_dirs(self) + if self.path not in include_dirs: + include_dirs.append(self.path) for p in self._manifest.get("extraIncludes", []): - inc_dirs.append(join(self.path, p)) - return inc_dirs + include_dirs.append(join(self.path, p)) + return include_dirs def is_frameworks_compatible(self, frameworks): return self.items_in_list(frameworks, ["mbed"]) @@ -592,34 +614,48 @@ class PlatformIOLibBuilder(LibBuilderBase): return LibBuilderBase.is_frameworks_compatible(self, frameworks) return self.items_in_list(frameworks, items) - def get_inc_dirs(self): - inc_dirs = LibBuilderBase.get_inc_dirs(self) + def get_include_dirs(self): + include_dirs = LibBuilderBase.get_include_dirs(self) - # backwards compatibility with PlatformIO 2.0 + # backwards compatibility with PlatformIO 2.0 if ("build" not in self._manifest and self._is_arduino_manifest() and not isdir(join(self.path, "src")) and isdir(join(self.path, "utility"))): - inc_dirs.append(join(self.path, "utility")) + include_dirs.append(join(self.path, "utility")) for path in self.env.get("CPPPATH", []): if path not in self.envorigin.get("CPPPATH", []): - inc_dirs.append(self.env.subst(path)) - return inc_dirs + include_dirs.append(self.env.subst(path)) + return include_dirs class ProjectAsLibBuilder(LibBuilderBase): + @property + def include_dir(self): + include_dir = self.env.subst("$PROJECTINCLUDE_DIR") + return include_dir if isdir(include_dir) else None + @property def src_dir(self): return self.env.subst("$PROJECTSRC_DIR") - def get_inc_dirs(self): - inc_dirs = LibBuilderBase.get_inc_dirs(self) - inc_dirs.append(self.env.subst("$PROJECTINCLUDE_DIR")) - return inc_dirs + def get_include_dirs(self): + include_dirs = LibBuilderBase.get_include_dirs(self) + include_dirs.append(self.env.subst("$PROJECTINCLUDE_DIR")) + return include_dirs - def get_src_files(self): - return self.env.get("PROJECTBUILDFILES", []) + def get_search_files(self): + # project files + items = LibBuilderBase.get_search_files(self) + # test files + if "__test" in COMMAND_LINE_TARGETS: + items.extend([ + join("$PROJECTTEST_DIR", item) + for item in self.env.MatchSourceFiles("$PROJECTTEST_DIR", + "$PIOTEST_SRC_FILTER") + ]) + return items @property def lib_ldf_mode(self): @@ -673,7 +709,7 @@ class ProjectAsLibBuilder(LibBuilderBase): def build(self): self._is_built = True # do not build Project now - self.env.AppendUnique(CPPPATH=self.get_inc_dirs()) + self.env.AppendUnique(CPPPATH=self.get_include_dirs()) return LibBuilderBase.build(self) @@ -753,7 +789,7 @@ def BuildProjectLibraries(env): found_lbs = [lb for lb in lib_builders if lb.dependent] for lb in lib_builders: if lb in found_lbs: - lb.search_deps_recursive(lb.get_src_files()) + lb.search_deps_recursive(lb.get_search_files()) for lb in lib_builders: for deplb in lb.depbuilders[:]: if deplb not in found_lbs: diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 16dae086..7c08237f 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -293,11 +293,12 @@ def ProcessTest(env): src_filter = ["+<*.cpp>", "+<*.c>"] if "PIOTEST" in env: src_filter.append("+<%s%s>" % (env['PIOTEST'], sep)) + env.Replace(PIOTEST_SRC_FILTER=src_filter) return env.CollectBuildFiles( "$BUILDTEST_DIR", "$PROJECTTEST_DIR", - src_filter=src_filter, + "$PIOTEST_SRC_FILTER", duplicate=False) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index adfd6209..dd6be6a4 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -63,16 +63,14 @@ def BuildProgram(env): # Search for project source files env.Append( LIBPATH=["$BUILD_DIR"], - PROJECTBUILDFILES=env.CollectBuildFiles( - "$BUILDSRC_DIR", - "$PROJECTSRC_DIR", - src_filter=env.get("SRC_FILTER"), + PIOBUILDFILES=env.CollectBuildFiles( + "$BUILDSRC_DIR", "$PROJECTSRC_DIR", "$SRC_FILTER", duplicate=False)) if "__debug" in COMMAND_LINE_TARGETS: env.ProcessDebug() if "__test" in COMMAND_LINE_TARGETS: - env.Append(PROJECTBUILDFILES=env.ProcessTest()) + env.Append(PIOBUILDFILES=env.ProcessTest()) # build dependent libs env.Append(LIBS=env.BuildProjectLibraries()) @@ -90,15 +88,14 @@ def BuildProgram(env): # Handle SRC_BUILD_FLAGS env.ProcessFlags(env.get("SRC_BUILD_FLAGS")) - if not env.get("PROJECTBUILDFILES") and not COMMAND_LINE_TARGETS: + if not env.get("PIOBUILDFILES") and not COMMAND_LINE_TARGETS: sys.stderr.write( "Error: Nothing to build. Please put your source code files " "to '%s' folder\n" % env.subst("$PROJECTSRC_DIR")) env.Exit(1) program = env.Program( - join("$BUILD_DIR", env.subst("$PROGNAME")), - env['PROJECTBUILDFILES'] + env.get("PIOBUILDFILES", [])) + join("$BUILD_DIR", env.subst("$PROGNAME")), env['PIOBUILDFILES']) checksize_action = Action(env.CheckUploadSize, "Checking program size") AlwaysBuild(env.Alias("checkprogsize", program, checksize_action)) @@ -186,6 +183,7 @@ def MatchSourceFiles(env, src_dir, src_filter=None): items.add(item.replace(src_dir + sep, "")) src_dir = env.subst(src_dir) + src_filter = env.subst(src_filter) if src_filter else None src_filter = src_filter or SRC_FILTER_DEFAULT if isinstance(src_filter, (list, tuple)): src_filter = " ".join(src_filter) @@ -270,12 +268,12 @@ def BuildLibrary(env, variant_dir, src_dir, src_filter=None): lib = env.Clone() return lib.StaticLibrary( lib.subst(variant_dir), - lib.CollectBuildFiles(variant_dir, src_dir, src_filter=src_filter)) + lib.CollectBuildFiles(variant_dir, src_dir, src_filter)) def BuildSources(env, variant_dir, src_dir, src_filter=None): DefaultEnvironment().Append(PIOBUILDFILES=env.Clone().CollectBuildFiles( - variant_dir, src_dir, src_filter=src_filter)) + variant_dir, src_dir, src_filter)) def exists(_): From cee2da744856188040fc06ef443cab9a15bc527b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Dec 2017 16:16:07 +0200 Subject: [PATCH 171/211] Bump version to 3.5.0rc10 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 12dc1830..89543bc7 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc9") +VERSION = (3, 5, "0rc10") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From efceb5db72917b861b9a6d7dc03adb9f11be68db Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Dec 2017 17:40:56 +0200 Subject: [PATCH 172/211] Explain that we need Internet connection to install all dependencies --- platformio/exception.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platformio/exception.py b/platformio/exception.py index e190d7a4..5c8f93a6 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -164,7 +164,9 @@ class APIRequestError(PlatformioException): class InternetIsOffline(PlatformioException): - MESSAGE = "You are not connected to the Internet" + MESSAGE = "You are not connected to the Internet.\n"\ + "If you build a project first time, we need Internet "\ + "connection to install all dependencies and toolchain." class LibNotFound(PlatformioException): From 170917a927c30c532601cf56735be96c3087a7b9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Dec 2017 19:19:08 +0200 Subject: [PATCH 173/211] Sync supported boards and frameworks --- docs | 2 +- scripts/docspregen.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs b/docs index 8e95f0d9..72b22750 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 8e95f0d9893cc5022968b60a43f6f3ddc32ffc2d +Subproject commit 72b22750fc5a6146be770a4deb5b4b897508a6f2 diff --git a/scripts/docspregen.py b/scripts/docspregen.py index 8b14713d..585b9ea2 100644 --- a/scripts/docspregen.py +++ b/scripts/docspregen.py @@ -335,7 +335,7 @@ Boards vendors = {} for data in BOARDS: - frameworks = data['frameworks'] + frameworks = data['frameworks'] or [] vendor = data['vendor'] if type_ in frameworks: if vendor in vendors: From cdf4639c9794cd6a0d9e94fe846508253817dc13 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 16 Dec 2017 20:50:25 +0200 Subject: [PATCH 174/211] Remove duplicate package versions from result --- platformio/managers/package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index ed5efe41..78be6f99 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -123,7 +123,7 @@ class PkgRepoMixin(object): for versions in PackageRepoIterator(name, self.repositories): result.extend( [semantic_version.Version(v['version']) for v in versions]) - return [str(v) for v in sorted(result)] + return [str(v) for v in sorted(set(result))] class PkgInstallerMixin(object): From cbb7db552a5a316d84c6cdf13981c14930726a0a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 17 Dec 2017 01:23:40 +0200 Subject: [PATCH 175/211] Add contents for "FAQ: Install PIO Core Shell Commands" --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 72b22750..a07f975a 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 72b22750fc5a6146be770a4deb5b4b897508a6f2 +Subproject commit a07f975a220eaf1e89b5be88972db2d4bc79f4e0 From 724135f40e0300d28748ad514fd6a7268472a1f2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 17 Dec 2017 01:58:43 +0200 Subject: [PATCH 176/211] Docs: Simplify solution for "PackageManager is unable to install tool" --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index a07f975a..a9a8554e 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit a07f975a220eaf1e89b5be88972db2d4bc79f4e0 +Subproject commit a9a8554ed0343d6a12ff750ee41feef15d875bc2 From 31814b51226b6f3ad45c22aa67a8fc93244f34a7 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 18 Dec 2017 21:31:49 +0200 Subject: [PATCH 177/211] Extend "pio device list" command with new options to list logical devices and multicast DNS services // Resolve #463 --- HISTORY.rst | 16 +++-- docs | 2 +- platformio/builder/tools/pioupload.py | 16 ++--- platformio/commands/device.py | 72 +++++++++++++++++--- platformio/util.py | 97 ++++++++++++++++++++++----- setup.py | 3 +- 6 files changed, 166 insertions(+), 40 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 71849c69..8eddb985 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -15,16 +15,24 @@ PlatformIO 3.0 * Allowed to depend on development platform using VSC URL (Git, Mercurial and Subversion) in `Project Configuration File "platformio.ini" `__ Dropped support for ``*_stage`` dev/platforms. Use VCS URL instead. -* Improvements to `Library Dependency Finder (LDF) `__: +* New options for `platformio device list `__ + command: - - Search for libraries used in test + - ``--serial`` list available serial ports (default) + - ``--logical`` list logical devices + - ``--mdns`` discover multicast DNS services + (`issue #463 `_) + +* `Library Dependency Finder (LDF) `__: + + - Search for dependencies used in `PIO Unit Testing `__ (`issue #953 `_) - Parse library source file in pair with a header when they have the same name (`issue #1175 `_) - Handle library dependencies defined as VCS or SemVer in - `Project Configuration File "platformio.ini" `__ + `Project Configuration File "platformio.ini" `__ (`issue #1155 `_) - - Added option to configure library `Compatible Mode `__ + - Added option to configure library `Compatible Mode `__ using `library.json `__ * Fixed platforms, packages, and libraries updating behind proxy diff --git a/docs b/docs index a9a8554e..0c984c49 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit a9a8554ed0343d6a12ff750ee41feef15d875bc2 +Subproject commit 0c984c49f2ad98ba37a00c5ab66773df613582ba diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index 36fbda8c..2d75c6a9 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -58,7 +58,7 @@ def WaitForNewSerialPort(env, before): elapsed = 0 before = [p['port'] for p in before] while elapsed < 5 and new_port is None: - now = [p['port'] for p in util.get_serialports()] + now = [p['port'] for p in util.get_serial_ports()] for p in now: if p not in before: new_port = p @@ -107,18 +107,18 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument def _look_for_mbed_disk(): msdlabels = ("mbed", "nucleo", "frdm", "microbit") - for item in util.get_logicaldisks(): - if item['disk'].startswith("/net") or not _is_match_pattern( - item['disk']): + for item in util.get_logical_devices(): + if item['device'].startswith("/net") or not _is_match_pattern( + item['device']): continue mbed_pages = [ - join(item['disk'], n) for n in ("mbed.htm", "mbed.html") + join(item['device'], n) for n in ("mbed.htm", "mbed.html") ] if any([isfile(p) for p in mbed_pages]): - return item['disk'] + return item['device'] if item['name'] \ and any([l in item['name'].lower() for l in msdlabels]): - return item['disk'] + return item['device'] return None def _look_for_serial_port(): @@ -127,7 +127,7 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument upload_protocol = env.subst("$UPLOAD_PROTOCOL") if "BOARD" in env and "build.hwids" in env.BoardConfig(): board_hwids = env.BoardConfig().get("build.hwids") - for item in util.get_serialports(filter_hwid=True): + for item in util.get_serial_ports(filter_hwid=True): if not _is_match_pattern(item['port']): continue port = item['port'] diff --git a/platformio/commands/device.py b/platformio/commands/device.py index f4094cc3..5d71c223 100644 --- a/platformio/commands/device.py +++ b/platformio/commands/device.py @@ -28,17 +28,69 @@ def cli(): @cli.command("list", short_help="List devices") +@click.option("--serial", is_flag=True, help="List serial ports, default") +@click.option("--logical", is_flag=True, help="List logical devices") +@click.option("--mdns", is_flag=True, help="List multicast DNS services") @click.option("--json-output", is_flag=True) -def device_list(json_output): - if json_output: - return click.echo(json.dumps(util.get_serialports())) +def device_list( # pylint: disable=too-many-branches + serial, logical, mdns, json_output): + if not logical and not mdns: + serial = True + data = {} + if serial: + data['serial'] = util.get_serial_ports() + if logical: + data['logical'] = util.get_logical_devices() + if mdns: + data['mdns'] = util.get_mdns_services() - for item in util.get_serialports(): - click.secho(item['port'], fg="cyan") - click.echo("-" * len(item['port'])) - click.echo("Hardware ID: %s" % item['hwid']) - click.echo("Description: %s" % item['description']) - click.echo("") + single_key = data.keys()[0] if len(data.keys()) == 1 else None + + if json_output: + return click.echo(json.dumps(data[single_key] if single_key else data)) + + titles = { + "serial": "Serial Ports", + "logical": "Logical Devices", + "mdns": "Multicast DNS Services" + } + + for key, value in data.iteritems(): + if not single_key: + click.secho(titles[key], bold=True) + click.echo("=" * len(titles[key])) + + if key == "serial": + for item in value: + click.secho(item['port'], fg="cyan") + click.echo("-" * len(item['port'])) + click.echo("Hardware ID: %s" % item['hwid']) + click.echo("Description: %s" % item['description']) + click.echo("") + + if key == "logical": + for item in value: + click.secho(item['device'], fg="cyan") + click.echo("-" * len(item['device'])) + click.echo("Name: %s" % item['name']) + click.echo("") + + if key == "mdns": + for item in value: + click.secho(item['name'], fg="cyan") + click.echo("-" * len(item['name'])) + click.echo("Type: %s" % item['type']) + click.echo("IP: %s" % item['ip']) + click.echo("Port: %s" % item['port']) + if item['properties']: + click.echo("Properties: %s" % ("; ".join([ + "%s=%s" % (k, v) + for k, v in item['properties'].iteritems() + ]))) + click.echo("") + + if single_key: + click.echo("") return True @@ -123,7 +175,7 @@ def device_monitor(**kwargs): # pylint: disable=too-many-branches pass if not kwargs['port']: - ports = util.get_serialports(filter_hwid=True) + ports = util.get_serial_ports(filter_hwid=True) if len(ports) == 1: kwargs['port'] = ports[0]['port'] diff --git a/platformio/util.py b/platformio/util.py index ee295fb0..0669aaad 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -32,6 +32,7 @@ from time import sleep, time import click import requests +import zeroconf from platformio import __apiurl__, __version__, exception @@ -417,7 +418,7 @@ def copy_pythonpath_to_osenv(): os.environ['PYTHONPATH'] = os.pathsep.join(_PYTHONPATH) -def get_serialports(filter_hwid=False): +def get_serial_ports(filter_hwid=False): try: from serial.tools.list_ports import comports except ImportError: @@ -445,42 +446,106 @@ def get_serialports(filter_hwid=False): return result -def get_logicaldisks(): - disks = [] +def get_logical_devices(): + items = [] if platform.system() == "Windows": try: result = exec_command( ["wmic", "logicaldisk", "get", "name,VolumeName"]).get( "out", "") - disknamere = re.compile(r"^([A-Z]{1}\:)\s*(\S+)?") + devicenamere = re.compile(r"^([A-Z]{1}\:)\s*(\S+)?") for line in result.split("\n"): - match = disknamere.match(line.strip()) + match = devicenamere.match(line.strip()) if not match: continue - disks.append({ - "disk": match.group(1) + "\\", + items.append({ + "device": match.group(1) + "\\", "name": match.group(2) }) - return disks + return items except WindowsError: # pylint: disable=undefined-variable pass # try "fsutil" result = exec_command(["fsutil", "fsinfo", "drives"]).get("out", "") - for disk in re.findall(r"[A-Z]:\\", result): - disks.append({"disk": disk, "name": None}) - return disks + for device in re.findall(r"[A-Z]:\\", result): + items.append({"device": device, "name": None}) + return items else: result = exec_command(["df"]).get("out") - disknamere = re.compile(r"^/.+\d+\%\s+([a-z\d\-_/]+)$", flags=re.I) + devicenamere = re.compile(r"^/.+\d+\%\s+([a-z\d\-_/]+)$", flags=re.I) for line in result.split("\n"): - match = disknamere.match(line.strip()) + match = devicenamere.match(line.strip()) if not match: continue - disks.append({ - "disk": match.group(1), + items.append({ + "device": match.group(1), "name": basename(match.group(1)) }) - return disks + return items + + +### Backward compatibility for PIO Core <3.5 +get_serialports = get_serial_ports +get_logicaldisks = lambda: [{ + "disk": d['device'], + "name": d['name'] +} for d in get_logical_devices()] + + +def get_mdns_services(): + + class mDNSListener(object): + + def __init__(self): + self._zc = zeroconf.Zeroconf( + interfaces=zeroconf.InterfaceChoice.All) + self._found_types = [] + self._found_services = [] + + def __enter__(self): + zeroconf.ServiceBrowser(self._zc, "_services._dns-sd._udp.local.", + self) + return self + + def __exit__(self, etype, value, traceback): + self._zc.close() + + def remove_service(self, zc, type_, name): + pass + + def add_service(self, zc, type_, name): + try: + zeroconf.service_type_name(name) + except zeroconf.BadTypeInNameException: + return + if name not in self._found_types: + self._found_types.append(name) + zeroconf.ServiceBrowser(self._zc, name, self) + if type_ in self._found_types: + s = zc.get_service_info(type_, name) + if s: + self._found_services.append(s) + + def get_services(self): + return self._found_services + + items = [] + with mDNSListener() as mdns: + sleep(5) + for service in mdns.get_services(): + items.append({ + "type": + service.type, + "name": + service.name, + "ip": + ".".join([str(ord(c)) for c in service.address]), + "port": + service.port, + "properties": + service.properties + }) + return items def get_request_defheaders(): diff --git a/setup.py b/setup.py index dceee7b2..11476caa 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,8 @@ install_requires = [ "lockfile>=0.9.1,<0.13", "pyserial>=3,<4,!=3.3", "requests>=2.4.0,<3", - "semantic_version>=2.5.0,<3" + "semantic_version>=2.5.0,<3", + "zeroconf<=0.19.1" ] setup( From 5dd97a35ccf98edde091a6df6916e69a8d0591b7 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 00:51:35 +0200 Subject: [PATCH 178/211] Reinstall/redownload package with a new ``-f, --force`` option // Resolve #778 --- HISTORY.rst | 27 ++++++++++++++++----------- docs | 2 +- platformio/commands/lib.py | 10 ++++++++-- platformio/commands/platform.py | 10 ++++++++-- platformio/managers/lib.py | 29 ++++++++++++++++++++++------- platformio/managers/package.py | 7 ++++++- platformio/managers/platform.py | 23 ++++++++++++++--------- 7 files changed, 75 insertions(+), 33 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 8eddb985..35418484 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -9,19 +9,16 @@ PlatformIO 3.0 * PIO Home * Integration with `Jenkins CI `_ -* Added `include `__ +* New `include `__ folder for project's header files (`issue #1107 `_) -* Allowed to depend on development platform using VSC URL (Git, Mercurial and Subversion) - in `Project Configuration File "platformio.ini" `__ - Dropped support for ``*_stage`` dev/platforms. Use VCS URL instead. -* New options for `platformio device list `__ - command: - - - ``--serial`` list available serial ports (default) - - ``--logical`` list logical devices - - ``--mdns`` discover multicast DNS services - (`issue #463 `_) +* Depend on development platform using VSC URL (Git, Mercurial and Subversion) instead of a name + in `Project Configuration File "platformio.ini" `__. + Drop support for ``*_stage`` dev/platform names (use VCS URL instead). +* Reinstall/redownload package with a new ``-f, --force`` option for `platformio lib install `__ + and `platformio platform install `__ + commands + (`issue #778 `_) * `Library Dependency Finder (LDF) `__: @@ -35,6 +32,14 @@ PlatformIO 3.0 - Added option to configure library `Compatible Mode `__ using `library.json `__ +* New options for `platformio device list `__ + command: + + - ``--serial`` list available serial ports (default) + - ``--logical`` list logical devices + - ``--mdns`` discover multicast DNS services + (`issue #463 `_) + * Fixed platforms, packages, and libraries updating behind proxy (`issue #1061 `_) * Fixed missing toolchain include paths for project generator diff --git a/docs b/docs index 0c984c49..441416c3 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 0c984c49f2ad98ba37a00c5ab66773df613582ba +Subproject commit 441416c3802d961df6e4083990b2e162a1835acb diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index e3338816..ddb4c7e7 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -93,11 +93,17 @@ def cli(ctx, **options): "--interactive", is_flag=True, help="Allow to make a choice for all prompts") +@click.option( + "-f", + "--force", + is_flag=True, + help="Reinstall/redownload library if exists") @click.pass_obj -def lib_install(lm, libraries, silent, interactive): +def lib_install(lm, libraries, silent, interactive, force): # @TODO "save" option for library in libraries: - lm.install(library, silent=silent, interactive=interactive) + lm.install( + library, silent=silent, interactive=interactive, force=force) @cli.command("uninstall", short_help="Uninstall libraries") diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index ff54bc9f..8fcc70b0 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -295,15 +295,21 @@ def platform_show(platform, json_output): # pylint: disable=too-many-branches @click.option("--with-package", multiple=True) @click.option("--without-package", multiple=True) @click.option("--skip-default-package", is_flag=True) +@click.option( + "-f", + "--force", + is_flag=True, + help="Reinstall/redownload dev/platform and its packages if exist") def platform_install(platforms, with_package, without_package, - skip_default_package): + skip_default_package, force): pm = PlatformManager() for platform in platforms: if pm.install( name=platform, with_packages=with_package, without_packages=without_package, - skip_default_package=skip_default_package): + skip_default_package=skip_default_package, + force=force): click.secho( "The platform '%s' has been successfully installed!\n" "The rest of packages will be installed automatically " diff --git a/platformio/managers/lib.py b/platformio/managers/lib.py index 2b20768d..48cba9b5 100644 --- a/platformio/managers/lib.py +++ b/platformio/managers/lib.py @@ -240,7 +240,8 @@ class LibraryManager(BasePkgManager): requirements=None, silent=False, trigger_event=True, - interactive=False): + interactive=False, + force=False): pkg_dir = None try: _name, _requirements, _url = self.parse_pkg_uri(name, requirements) @@ -251,8 +252,13 @@ class LibraryManager(BasePkgManager): silent=silent, interactive=interactive) requirements = _requirements - pkg_dir = BasePkgManager.install(self, name, requirements, silent, - trigger_event) + pkg_dir = BasePkgManager.install( + self, + name, + requirements, + silent=silent, + trigger_event=trigger_event, + force=force) except exception.InternetIsOffline as e: if not silent: click.secho(str(e), fg="yellow") @@ -271,7 +277,12 @@ class LibraryManager(BasePkgManager): for filters in self.normalize_dependencies(manifest['dependencies']): assert "name" in filters if any([s in filters.get("version", "") for s in ("\\", "/")]): - self.install("{name}={version}".format(**filters)) + self.install( + "{name}={version}".format(**filters), + silent=silent, + trigger_event=trigger_event, + interactive=interactive, + force=force) else: try: lib_info = self.search_for_library(filters, silent, @@ -284,14 +295,18 @@ class LibraryManager(BasePkgManager): if filters.get("version"): self.install( lib_info['id'], - requirements=filters.get("version"), + filters.get("version"), silent=silent, - trigger_event=trigger_event) + trigger_event=trigger_event, + interactive=interactive, + force=force) else: self.install( lib_info['id'], silent=silent, - trigger_event=trigger_event) + trigger_event=trigger_event, + interactive=interactive, + force=force) return pkg_dir @staticmethod diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 78be6f99..e8e6dfdd 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -602,7 +602,8 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): name, requirements=None, silent=False, - trigger_event=True): + trigger_event=True, + force=False): name, requirements, url = self.parse_pkg_uri(name, requirements) package_dir = self.get_package_dir(name, requirements, url) @@ -614,6 +615,10 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): return package_dir self.INSTALL_HISTORY.append(history_key) + if package_dir and force: + self.uninstall(package_dir) + package_dir = None + if not package_dir or not silent: msg = "Installing " + click.style(name, fg="cyan") if requirements: diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index f0baf36d..c97d62c2 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -63,9 +63,10 @@ class PlatformManager(BasePkgManager): skip_default_package=False, trigger_event=True, silent=False, + force=False, **_): # pylint: disable=too-many-arguments, arguments-differ platform_dir = BasePkgManager.install( - self, name, requirements, silent=silent) + self, name, requirements, silent=silent, force=force) p = PlatformFactory.newPlatform(platform_dir) # @Hook: when 'update' operation (trigger_event is False), @@ -76,7 +77,8 @@ class PlatformManager(BasePkgManager): with_packages, without_packages, skip_default_package, - silent=silent) + silent=silent, + force=force) self.cleanup_packages(p.packages.keys()) return True @@ -248,11 +250,13 @@ class PlatformFactory(object): class PlatformPackagesMixin(object): - def install_packages(self, - with_packages=None, - without_packages=None, - skip_default_package=False, - silent=False): + def install_packages( # pylint: disable=too-many-arguments + self, + with_packages=None, + without_packages=None, + skip_default_package=False, + silent=False, + force=False): with_packages = set(self.find_pkg_names(with_packages or [])) without_packages = set(self.find_pkg_names(without_packages or [])) @@ -268,9 +272,10 @@ class PlatformPackagesMixin(object): elif (name in with_packages or not (skip_default_package or opts.get("optional", False))): if ":" in version: - self.pm.install("%s=%s" % (name, version), silent=silent) + self.pm.install( + "%s=%s" % (name, version), silent=silent, force=force) else: - self.pm.install(name, version, silent=silent) + self.pm.install(name, version, silent=silent, force=force) return True From 9441f776cc7d9add4eb0dcb128134507a56bfc71 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 01:41:18 +0200 Subject: [PATCH 179/211] Handle missed dependency and provide a help how to find it using PlatformIO Library Registry // Resolve #781 --- HISTORY.rst | 2 ++ platformio/managers/platform.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 35418484..0e0ee9ab 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -19,6 +19,8 @@ PlatformIO 3.0 and `platformio platform install `__ commands (`issue #778 `_) +* Handle missed dependency and provide a help how to find it using PlatformIO Library Registry + (`issue #781 `_) * `Library Dependency Finder (LDF) `__: diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index c97d62c2..b3090705 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -18,6 +18,7 @@ import re from imp import load_source from multiprocessing import cpu_count from os.path import basename, dirname, isdir, isfile, join +from urllib import quote import click import semantic_version @@ -394,6 +395,12 @@ class PlatformRunMixin(object): is_error = self.LINE_ERROR_RE.search(line) is not None self._echo_line(line, level=3 if is_error else 2) + a_pos = line.find("fatal error:") + b_pos = line.rfind(": No such file or directory") + if a_pos == -1 or b_pos == -1: + return + self._echo_missed_dependency(line[a_pos + 12:b_pos].strip()) + def _echo_line(self, line, level): if line.startswith("scons: "): line = line[7:] @@ -405,6 +412,27 @@ class PlatformRunMixin(object): fg = "green" click.secho(line, fg=fg, err=level > 1) + @staticmethod + def _echo_missed_dependency(filename): + if "/" in filename or not filename.endswith((".h", ".hpp")): + return + banner = """ +{dots} +* Looking for {filename_styled} dependency? Check our library registry! +* +* CLI > platformio lib search "header:{filename}" +* Web > {link} +* +{dots} +""".format(filename=filename, + filename_styled=click.style(filename, fg="cyan"), + link=click.style( + "http://platformio.org/lib/search?query=header:%s" % quote( + filename, safe=""), + fg="blue"), + dots="*" * (55 + len(filename))) + click.echo(banner, err=True) + @staticmethod def get_job_nums(): try: From 903ad6c6f8cbbbe57c683c8a888a7b5556c79b81 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 01:42:10 +0200 Subject: [PATCH 180/211] Bump version to 3.5.0rc11 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 89543bc7..88a1f109 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc10") +VERSION = (3, 5, "0rc11") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 78b296f2ecf2decb4eea63d761638c6a7ca93489 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 01:49:25 +0200 Subject: [PATCH 181/211] Update changelog --- HISTORY.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 0e0ee9ab..8ad7ff08 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -19,7 +19,7 @@ PlatformIO 3.0 and `platformio platform install `__ commands (`issue #778 `_) -* Handle missed dependency and provide a help how to find it using PlatformIO Library Registry +* Handle missed dependencies and provide a solution based on PlatformIO Library Registry (`issue #781 `_) * `Library Dependency Finder (LDF) `__: From 9f2875fcd74c858f6dfe6e294f7aa9e5db77cccf Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 01:55:51 +0200 Subject: [PATCH 182/211] Update changelog with missed records --- HISTORY.rst | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 8ad7ff08..e7a9c16f 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,15 +12,20 @@ PlatformIO 3.0 * New `include `__ folder for project's header files (`issue #1107 `_) -* Depend on development platform using VSC URL (Git, Mercurial and Subversion) instead of a name - in `Project Configuration File "platformio.ini" `__. +* Depend on development platform using VSC URL (Git, Mercurial and Subversion) + instead of a name in `Project Configuration File "platformio.ini" `__. Drop support for ``*_stage`` dev/platform names (use VCS URL instead). -* Reinstall/redownload package with a new ``-f, --force`` option for `platformio lib install `__ +* Reinstall/redownload package with a new ``-f, --force`` option for + `platformio lib install `__ and `platformio platform install `__ commands (`issue #778 `_) -* Handle missed dependencies and provide a solution based on PlatformIO Library Registry +* Handle missed dependencies and provide a solution based on PlatformIO Library + Registry (`issue #781 `_) +* New setting `projects_dir `__ + that allows to override a default PIO Home Projects location + (`issue #1161 `_) * `Library Dependency Finder (LDF) `__: From c6abdf8206b4ed156bdffb6cd481d1eda8e12250 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 12:41:56 +0200 Subject: [PATCH 183/211] Check zeroconf installation before adding to setuptools --- platformio/exception.py | 7 +++++++ platformio/util.py | 5 ++++- setup.py | 19 +++++++++++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/platformio/exception.py b/platformio/exception.py index 5c8f93a6..5f7abe7f 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -227,3 +227,10 @@ class CygwinEnvDetected(PlatformioException): MESSAGE = "PlatformIO does not work within Cygwin environment. "\ "Use native Terminal instead." + + +class ZeroconfIsNotInstalled(PlatformioException): + + MESSAGE = "Python multicast DNS service discovery library has not been "\ + "installed automatically. Please open terminal and run \n"\ + "> pip install zeroconf" diff --git a/platformio/util.py b/platformio/util.py index 0669aaad..7ab4ed7a 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -32,7 +32,6 @@ from time import sleep, time import click import requests -import zeroconf from platformio import __apiurl__, __version__, exception @@ -493,6 +492,10 @@ get_logicaldisks = lambda: [{ def get_mdns_services(): + try: + import zeroconf + except ImportError: + raise exception.ZeroconfIsNotInstalled() class mDNSListener(object): diff --git a/setup.py b/setup.py index 11476caa..b0f442e0 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import subprocess +import sys +from os.path import normpath from setuptools import find_packages, setup from platformio import (__author__, __description__, __email__, __license__, @@ -25,9 +28,21 @@ install_requires = [ "lockfile>=0.9.1,<0.13", "pyserial>=3,<4,!=3.3", "requests>=2.4.0,<3", - "semantic_version>=2.5.0,<3", - "zeroconf<=0.19.1" + "semantic_version>=2.5.0,<3" ] +zeroconf_requirement = "zeroconf<=0.19.1" + +try: + import zeroconf # pylint: disable=unused-import +except ImportError: + try: + subprocess.check_call([ + normpath(sys.executable), "-m", "pip", "install", + zeroconf_requirement + ]) + install_requires.append(zeroconf_requirement) + except: # pylint: disable=bare-except + pass setup( name=__title__, From 0c3f2b54ed37e57a944643f192753d854695bbba Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 12:42:18 +0200 Subject: [PATCH 184/211] Bump version to 3.5.0rc12 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 88a1f109..21615ff6 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc11") +VERSION = (3, 5, "0rc12") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From a6c1869eb22be41c2910e20814a4cd4b26183a47 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 14:47:31 +0200 Subject: [PATCH 185/211] Depend on "zeroconf" from "contrib-pysite" --- platformio/exception.py | 7 ------- platformio/managers/core.py | 4 ++-- platformio/util.py | 7 ++++++- setup.py | 16 ---------------- 4 files changed, 8 insertions(+), 26 deletions(-) diff --git a/platformio/exception.py b/platformio/exception.py index 5f7abe7f..5c8f93a6 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -227,10 +227,3 @@ class CygwinEnvDetected(PlatformioException): MESSAGE = "PlatformIO does not work within Cygwin environment. "\ "Use native Terminal instead." - - -class ZeroconfIsNotInstalled(PlatformioException): - - MESSAGE = "Python multicast DNS service discovery library has not been "\ - "installed automatically. Please open terminal and run \n"\ - "> pip install zeroconf" diff --git a/platformio/managers/core.py b/platformio/managers/core.py index 5c508498..fffdd038 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -22,7 +22,7 @@ from platformio.managers.package import PackageManager CORE_PACKAGES = { "contrib-piohome": ">=0.5.3,<2", - "pysite-pioplus": ">=0.4.2,<2", + "contrib-pysite": ">=0.1.0,<2", "tool-pioplus": ">=0.12.1,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" @@ -105,7 +105,7 @@ def pioplus_call(args, **kwargs): pioplus_path = join(get_core_package_dir("tool-pioplus"), "pioplus") pythonexe_path = util.get_pythonexe_path() os.environ['PYTHONEXEPATH'] = pythonexe_path - os.environ['PYTHONPYSITEDIR'] = get_core_package_dir("pysite-pioplus") + os.environ['PYTHONPYSITEDIR'] = get_core_package_dir("contrib-pysite") os.environ['PATH'] = (os.pathsep).join( [dirname(pythonexe_path), os.environ['PATH']]) util.copy_pythonpath_to_osenv() diff --git a/platformio/util.py b/platformio/util.py index 7ab4ed7a..1d9872bf 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -495,7 +495,12 @@ def get_mdns_services(): try: import zeroconf except ImportError: - raise exception.ZeroconfIsNotInstalled() + from site import addsitedir + from platformio.managers.core import get_core_package_dir + contrib_pysite_dir = get_core_package_dir("contrib-pysite") + addsitedir(contrib_pysite_dir) + sys.path.insert(0, contrib_pysite_dir) + import zeroconf class mDNSListener(object): diff --git a/setup.py b/setup.py index b0f442e0..dceee7b2 100644 --- a/setup.py +++ b/setup.py @@ -12,9 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import subprocess -import sys -from os.path import normpath from setuptools import find_packages, setup from platformio import (__author__, __description__, __email__, __license__, @@ -30,19 +27,6 @@ install_requires = [ "requests>=2.4.0,<3", "semantic_version>=2.5.0,<3" ] -zeroconf_requirement = "zeroconf<=0.19.1" - -try: - import zeroconf # pylint: disable=unused-import -except ImportError: - try: - subprocess.check_call([ - normpath(sys.executable), "-m", "pip", "install", - zeroconf_requirement - ]) - install_requires.append(zeroconf_requirement) - except: # pylint: disable=bare-except - pass setup( name=__title__, From 6d81c230a5af0ab23833422c29ee650c023500fc Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 14:48:07 +0200 Subject: [PATCH 186/211] Bump version to 3.5.0rc13 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 21615ff6..ad76a66c 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc12") +VERSION = (3, 5, "0rc13") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 7b8c68c934ecbf3d797b775cf1763b8e7a8482c8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 15:05:41 +0200 Subject: [PATCH 187/211] Show error information when permissions are broken to PIO home dir --- platformio/app.py | 21 ++++++++++++--------- platformio/exception.py | 6 ++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/platformio/app.py b/platformio/app.py index 44962a23..7b5eaa58 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -25,7 +25,6 @@ import requests from lockfile import LockFailed, LockFile from platformio import __version__, exception, util -from platformio.exception import InvalidSettingName, InvalidSettingValue def projects_dir_validate(projects_dir): @@ -106,11 +105,14 @@ class State(object): def __exit__(self, type_, value, traceback): if self._prev_state != self._state: - with open(self.path, "w") as fp: - if "dev" in __version__: - json.dump(self._state, fp, indent=4) - else: - json.dump(self._state, fp) + try: + with open(self.path, "w") as fp: + if "dev" in __version__: + json.dump(self._state, fp, indent=4) + else: + json.dump(self._state, fp) + except IOError: + raise exception.HomeDirPermissionsError(util.get_home_dir()) self._unlock_state_file() def _lock_state_file(self): @@ -276,7 +278,7 @@ def clean_cache(): def sanitize_setting(name, value): if name not in DEFAULT_SETTINGS: - raise InvalidSettingName(name) + raise exception.InvalidSettingName(name) defdata = DEFAULT_SETTINGS[name] try: @@ -288,7 +290,7 @@ def sanitize_setting(name, value): elif isinstance(defdata['value'], int): value = int(value) except Exception: - raise InvalidSettingValue(value, name) + raise exception.InvalidSettingValue(value, name) return value @@ -367,5 +369,6 @@ def get_cid(): uuid.UUID( bytes=hashlib.md5(str(_uid if _uid else uuid.getnode())) .digest())) - set_state_item("cid", cid) + if "windows" in util.get_systype() or os.getuid() > 0: + set_state_item("cid", cid) return cid diff --git a/platformio/exception.py b/platformio/exception.py index 5c8f93a6..b38e91da 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -223,6 +223,12 @@ class UpgradeError(PlatformioException): """ +class HomeDirPermissionsError(PlatformioException): + + MESSAGE = "You do not have permissions to PlatformIO home directory.\n"\ + "Please remove `{0}` folder manually and repeat operation." + + class CygwinEnvDetected(PlatformioException): MESSAGE = "PlatformIO does not work within Cygwin environment. "\ From 39dfbbdd87aea5749871546dea2243154b7c20bb Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 15:24:23 +0200 Subject: [PATCH 188/211] Don't create "packages" directory when there are no packages isntalled --- platformio/managers/core.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index fffdd038..6c0b2024 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -15,7 +15,7 @@ import os import subprocess import sys -from os.path import dirname, join +from os.path import dirname, isdir, join from platformio import __version__, exception, util from platformio.managers.package import PackageManager @@ -35,8 +35,10 @@ PIOPLUS_AUTO_UPDATES_MAX = 100 class CorePackageManager(PackageManager): + CORE_PACKAGES_DIR = join(util.get_home_dir(), "packages") + def __init__(self): - PackageManager.__init__(self, join(util.get_home_dir(), "packages"), [ + PackageManager.__init__(self, CorePackageManager.CORE_PACKAGES_DIR, [ "https://dl.bintray.com/platformio/dl-packages/manifest.json", "http%s://dl.platformio.org/packages/manifest.json" % ("" if sys.version_info < (2, 7, 9) else "s") @@ -85,6 +87,8 @@ def get_core_package_dir(name): def update_core_packages(only_check=False, silent=False): + if not isdir(CorePackageManager.CORE_PACKAGES_DIR): + return None pm = CorePackageManager() for name, requirements in CORE_PACKAGES.items(): pkg_dir = pm.get_package_dir(name) @@ -92,6 +96,7 @@ def update_core_packages(only_check=False, silent=False): continue if not silent or pm.outdated(pkg_dir, requirements): pm.update(name, requirements, only_check=only_check) + return True def pioplus_call(args, **kwargs): From 06574e30668abeaaeb883d151e83bea36962739e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 15:38:32 +0200 Subject: [PATCH 189/211] Do not update automatically Core packages while upgrading PIO Core --- platformio/commands/upgrade.py | 4 ---- platformio/managers/core.py | 8 ++------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 1df215f9..97014d2b 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -19,16 +19,12 @@ import requests from platformio import VERSION, __version__, exception, util from platformio.commands.home import shutdown_servers -from platformio.managers.core import update_core_packages @click.command( "upgrade", short_help="Upgrade PlatformIO to the latest version") @click.option("--dev", is_flag=True, help="Use development branch") def cli(dev): - # Update PlatformIO's Core packages - update_core_packages(silent=True) - if not dev and __version__ == get_latest_version(): return click.secho( "You're up-to-date!\nPlatformIO %s is currently the " diff --git a/platformio/managers/core.py b/platformio/managers/core.py index 6c0b2024..180d092b 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -15,7 +15,7 @@ import os import subprocess import sys -from os.path import dirname, isdir, join +from os.path import dirname, join from platformio import __version__, exception, util from platformio.managers.package import PackageManager @@ -35,10 +35,8 @@ PIOPLUS_AUTO_UPDATES_MAX = 100 class CorePackageManager(PackageManager): - CORE_PACKAGES_DIR = join(util.get_home_dir(), "packages") - def __init__(self): - PackageManager.__init__(self, CorePackageManager.CORE_PACKAGES_DIR, [ + PackageManager.__init__(self, join(util.get_home_dir(), "packages"), [ "https://dl.bintray.com/platformio/dl-packages/manifest.json", "http%s://dl.platformio.org/packages/manifest.json" % ("" if sys.version_info < (2, 7, 9) else "s") @@ -87,8 +85,6 @@ def get_core_package_dir(name): def update_core_packages(only_check=False, silent=False): - if not isdir(CorePackageManager.CORE_PACKAGES_DIR): - return None pm = CorePackageManager() for name, requirements in CORE_PACKAGES.items(): pkg_dir = pm.get_package_dir(name) From d70a90f1d54f551523322797b37efe61d7c76680 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 15:49:44 +0200 Subject: [PATCH 190/211] Explain that no need to use `sudo pio ...` --- platformio/commands/lib.py | 3 +-- platformio/exception.py | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index ddb4c7e7..051720c6 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -33,8 +33,7 @@ from platformio.util import get_api_result "-g", "--global", is_flag=True, - help="Manage global PlatformIO" - " library storage `%s`" % join(util.get_home_dir(), "lib")) + help="Manage global PlatformIO library storage") @click.option( "-d", "--storage-dir", diff --git a/platformio/exception.py b/platformio/exception.py index b38e91da..4a1bdc66 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -226,7 +226,8 @@ class UpgradeError(PlatformioException): class HomeDirPermissionsError(PlatformioException): MESSAGE = "You do not have permissions to PlatformIO home directory.\n"\ - "Please remove `{0}` folder manually and repeat operation." + "Please remove `{0}` folder manually and avoid using " + "`sudo pio ...`." class CygwinEnvDetected(PlatformioException): From 1171cb204c8c5ef3eb379f94e66754eda43c310f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 16:50:09 +0200 Subject: [PATCH 191/211] Fix broken syntax --- platformio/exception.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/exception.py b/platformio/exception.py index 4a1bdc66..a2c8d9de 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -226,7 +226,7 @@ class UpgradeError(PlatformioException): class HomeDirPermissionsError(PlatformioException): MESSAGE = "You do not have permissions to PlatformIO home directory.\n"\ - "Please remove `{0}` folder manually and avoid using " + "Please remove `{0}` folder manually and avoid using "\ "`sudo pio ...`." From d16d715898bae287520841a5936217c6e53788e0 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 17:22:16 +0200 Subject: [PATCH 192/211] Bump version to 3.5.0rc14 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index ad76a66c..abd54ed5 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc13") +VERSION = (3, 5, "0rc14") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 2eb7d0e8be6dc1b48dc5155a9f55e3160d9821c2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Dec 2017 17:59:49 +0200 Subject: [PATCH 193/211] temporary switch to old "pysite-pioplus" --- platformio/managers/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index 180d092b..c70a547a 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -23,6 +23,7 @@ from platformio.managers.package import PackageManager CORE_PACKAGES = { "contrib-piohome": ">=0.5.3,<2", "contrib-pysite": ">=0.1.0,<2", + "pysite-pioplus": ">=0.4.2,<2", "tool-pioplus": ">=0.12.1,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" @@ -106,7 +107,7 @@ def pioplus_call(args, **kwargs): pioplus_path = join(get_core_package_dir("tool-pioplus"), "pioplus") pythonexe_path = util.get_pythonexe_path() os.environ['PYTHONEXEPATH'] = pythonexe_path - os.environ['PYTHONPYSITEDIR'] = get_core_package_dir("contrib-pysite") + os.environ['PYTHONPYSITEDIR'] = get_core_package_dir("pysite-pioplus") os.environ['PATH'] = (os.pathsep).join( [dirname(pythonexe_path), os.environ['PATH']]) util.copy_pythonpath_to_osenv() From adaa3757ac7036210e41e485abaa235d1f4a7ea3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 23 Dec 2017 13:06:38 +0200 Subject: [PATCH 194/211] Switch to newly created "contrib-pysite" --- platformio/managers/core.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index c70a547a..d75b063e 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -22,8 +22,7 @@ from platformio.managers.package import PackageManager CORE_PACKAGES = { "contrib-piohome": ">=0.5.3,<2", - "contrib-pysite": ">=0.1.0,<2", - "pysite-pioplus": ">=0.4.2,<2", + "contrib-pysite": ">=0.1.1,<2", "tool-pioplus": ">=0.12.1,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" @@ -107,7 +106,7 @@ def pioplus_call(args, **kwargs): pioplus_path = join(get_core_package_dir("tool-pioplus"), "pioplus") pythonexe_path = util.get_pythonexe_path() os.environ['PYTHONEXEPATH'] = pythonexe_path - os.environ['PYTHONPYSITEDIR'] = get_core_package_dir("pysite-pioplus") + os.environ['PYTHONPYSITEDIR'] = get_core_package_dir("contrib-pysite") os.environ['PATH'] = (os.pathsep).join( [dirname(pythonexe_path), os.environ['PATH']]) util.copy_pythonpath_to_osenv() From fab4f00ad4a80ca0dcdd74104e9f07b429d012a1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 23 Dec 2017 19:48:16 +0200 Subject: [PATCH 195/211] Reformat exceptions --- platformio/app.py | 8 +--- platformio/exception.py | 81 ++++++++++++++++++++++------------------- 2 files changed, 44 insertions(+), 45 deletions(-) diff --git a/platformio/app.py b/platformio/app.py index 7b5eaa58..f6015d36 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -127,13 +127,7 @@ class State(object): try: self._lockfile.acquire() except LockFailed: - raise exception.PlatformioException( - "The directory `{0}` or its parent directory is not owned by " - "the current user and PlatformIO can not store configuration " - "data. \nPlease check the permissions and owner of that " - "directory. Otherwise, please remove manually `{0}` " - "directory and PlatformIO will create new from the current " - "user.".format(dirname(self.path))) + raise exception.HomeDirPermissionsError(dirname(self.path)) def _unlock_state_file(self): if self._lockfile: diff --git a/platformio/exception.py b/platformio/exception.py index a2c8d9de..e477bd30 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -53,15 +53,15 @@ class IncompatiblePlatform(PlatformioException): class PlatformNotInstalledYet(PlatformioException): - MESSAGE = "The platform '{0}' has not been installed yet. "\ - "Use `platformio platform install {0}` command" + MESSAGE = ("The platform '{0}' has not been installed yet. " + "Use `platformio platform install {0}` command") class BoardNotDefined(PlatformioException): - MESSAGE = "You need to specify board ID using `-b` or `--board` "\ - "option. Supported boards list is available via "\ - "`platformio boards` command" + MESSAGE = ( + "You need to specify board ID using `-b` or `--board` option. " + "Supported boards list is available via `platformio boards` command") class UnknownBoard(PlatformioException): @@ -91,16 +91,16 @@ class MissingPackageManifest(PlatformioException): class UndefinedPackageVersion(PlatformioException): - MESSAGE = "Could not find a version that satisfies the requirement '{0}'"\ - " for your system '{1}'" + MESSAGE = ("Could not find a version that satisfies the requirement '{0}'" + " for your system '{1}'") class PackageInstallError(PlatformioException): - MESSAGE = "Could not install '{0}' with version requirements '{1}' "\ - "for your system '{2}'.\n"\ - "If you use Antivirus, it can block PlatformIO Package "\ - "Manager. Try to disable it for a while." + MESSAGE = ( + "Could not install '{0}' with version requirements '{1}' for your " + "system '{2}'.\n If you use Antivirus, it can block PlatformIO " + "Package Manager. Try to disable it for a while.") class FDUnrecognizedStatusCode(PlatformioException): @@ -110,21 +110,22 @@ class FDUnrecognizedStatusCode(PlatformioException): class FDSizeMismatch(PlatformioException): - MESSAGE = "The size ({0:d} bytes) of downloaded file '{1}' "\ - "is not equal to remote size ({2:d} bytes)" + MESSAGE = ("The size ({0:d} bytes) of downloaded file '{1}' " + "is not equal to remote size ({2:d} bytes)") class FDSHASumMismatch(PlatformioException): - MESSAGE = "The 'sha1' sum '{0}' of downloaded file '{1}' "\ - "is not equal to remote '{2}'" + MESSAGE = ("The 'sha1' sum '{0}' of downloaded file '{1}' " + "is not equal to remote '{2}'") class NotPlatformIOProject(PlatformioException): - MESSAGE = "Not a PlatformIO project. `platformio.ini` file has not been "\ - "found in current working directory ({0}). To initialize new project "\ - "please use `platformio init` command" + MESSAGE = ( + "Not a PlatformIO project. `platformio.ini` file has not been " + "found in current working directory ({0}). To initialize new project " + "please use `platformio init` command") class UndefinedEnvPlatform(PlatformioException): @@ -164,26 +165,27 @@ class APIRequestError(PlatformioException): class InternetIsOffline(PlatformioException): - MESSAGE = "You are not connected to the Internet.\n"\ - "If you build a project first time, we need Internet "\ - "connection to install all dependencies and toolchain." + MESSAGE = ( + "You are not connected to the Internet.\n" + "If you build a project first time, we need Internet connection " + "to install all dependencies and toolchain.") class LibNotFound(PlatformioException): - MESSAGE = "Library `{0}` has not been found in PlatformIO Registry.\n"\ - "You can ignore this message, if `{0}` is a built-in library "\ - "(included in framework, SDK). E.g., SPI, Wire, etc." + MESSAGE = ("Library `{0}` has not been found in PlatformIO Registry.\n" + "You can ignore this message, if `{0}` is a built-in library " + "(included in framework, SDK). E.g., SPI, Wire, etc.") class NotGlobalLibDir(PlatformioException): - MESSAGE = "The `{0}` is not a PlatformIO project.\n\n"\ - "To manage libraries "\ - "in global storage `{1}`,\n"\ - "please use `platformio lib --global {2}` or specify custom "\ - "storage `platformio lib --storage-dir /path/to/storage/ {2}`."\ - "\nCheck `platformio lib --help` for details." + MESSAGE = ( + "The `{0}` is not a PlatformIO project.\n\n" + "To manage libraries in global storage `{1}`,\n" + "please use `platformio lib --global {2}` or specify custom storage " + "`platformio lib --storage-dir /path/to/storage/ {2}`.\n" + "Check `platformio lib --help` for details.") class InvalidLibConfURL(PlatformioException): @@ -208,9 +210,9 @@ class InvalidSettingValue(PlatformioException): class CIBuildEnvsEmpty(PlatformioException): - MESSAGE = "Can't find PlatformIO build environments.\n"\ - "Please specify `--board` or path to `platformio.ini` with "\ - "predefined environments using `--project-conf` option" + MESSAGE = ("Can't find PlatformIO build environments.\n" + "Please specify `--board` or path to `platformio.ini` with " + "predefined environments using `--project-conf` option") class UpgradeError(PlatformioException): @@ -225,12 +227,15 @@ class UpgradeError(PlatformioException): class HomeDirPermissionsError(PlatformioException): - MESSAGE = "You do not have permissions to PlatformIO home directory.\n"\ - "Please remove `{0}` folder manually and avoid using "\ - "`sudo pio ...`." + MESSAGE = ( + "The directory `{0}` or its parent directory is not owned by the " + "current user and PlatformIO can not store configuration data.\n" + "Please check the permissions and owner of that directory.\n" + "Otherwise, please remove manually `{0}` directory and PlatformIO " + "will create new from the current user.") class CygwinEnvDetected(PlatformioException): - MESSAGE = "PlatformIO does not work within Cygwin environment. "\ - "Use native Terminal instead." + MESSAGE = ("PlatformIO does not work within Cygwin environment. " + "Use native Terminal instead.") From c96c1f2b2ffd5cc68bb71cfe2e96b10e76802b3a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 23 Dec 2017 21:05:05 +0200 Subject: [PATCH 196/211] Bump version to 3.5.0rc15 --- docs | 2 +- platformio/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs b/docs index 441416c3..8486fccd 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 441416c3802d961df6e4083990b2e162a1835acb +Subproject commit 8486fccd5043005ce8de7607cc814d6a619959a5 diff --git a/platformio/__init__.py b/platformio/__init__.py index abd54ed5..171302e6 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc14") +VERSION = (3, 5, "0rc15") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From e29ecb47a5d103e0215f0bb041e4b1942719b45b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 23 Dec 2017 22:59:49 +0200 Subject: [PATCH 197/211] Skip mDSN services with wrong encoding --- platformio/util.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platformio/util.py b/platformio/util.py index 1d9872bf..419fbd1c 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -523,8 +523,10 @@ def get_mdns_services(): def add_service(self, zc, type_, name): try: - zeroconf.service_type_name(name) - except zeroconf.BadTypeInNameException: + assert zeroconf.service_type_name(name) + assert str(name) + except (AssertionError, UnicodeError, + zeroconf.BadTypeInNameException): return if name not in self._found_types: self._found_types.append(name) @@ -539,7 +541,7 @@ def get_mdns_services(): items = [] with mDNSListener() as mdns: - sleep(5) + sleep(3) for service in mdns.get_services(): items.append({ "type": From 55d4fc23d076b8a2318e9a6fb387aa46e9dc5586 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 27 Dec 2017 16:02:36 +0200 Subject: [PATCH 198/211] Use "path" instead of "device" for logical devices --- docs | 2 +- platformio/builder/tools/pioupload.py | 10 +++++----- platformio/commands/device.py | 4 ++-- platformio/util.py | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs b/docs index 8486fccd..0403f687 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 8486fccd5043005ce8de7607cc814d6a619959a5 +Subproject commit 0403f687d6bca4f40a3e8ed2cfc2c635fc198516 diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index 2d75c6a9..ab7b27ca 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -108,17 +108,17 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument def _look_for_mbed_disk(): msdlabels = ("mbed", "nucleo", "frdm", "microbit") for item in util.get_logical_devices(): - if item['device'].startswith("/net") or not _is_match_pattern( - item['device']): + if item['path'].startswith("/net") or not _is_match_pattern( + item['path']): continue mbed_pages = [ - join(item['device'], n) for n in ("mbed.htm", "mbed.html") + join(item['path'], n) for n in ("mbed.htm", "mbed.html") ] if any([isfile(p) for p in mbed_pages]): - return item['device'] + return item['path'] if item['name'] \ and any([l in item['name'].lower() for l in msdlabels]): - return item['device'] + return item['path'] return None def _look_for_serial_port(): diff --git a/platformio/commands/device.py b/platformio/commands/device.py index 5d71c223..877b62e6 100644 --- a/platformio/commands/device.py +++ b/platformio/commands/device.py @@ -70,8 +70,8 @@ def device_list( # pylint: disable=too-many-branches if key == "logical": for item in value: - click.secho(item['device'], fg="cyan") - click.echo("-" * len(item['device'])) + click.secho(item['path'], fg="cyan") + click.echo("-" * len(item['path'])) click.echo("Name: %s" % item['name']) click.echo("") diff --git a/platformio/util.py b/platformio/util.py index 419fbd1c..a1c16b95 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -458,7 +458,7 @@ def get_logical_devices(): if not match: continue items.append({ - "device": match.group(1) + "\\", + "path": match.group(1) + "\\", "name": match.group(2) }) return items @@ -467,7 +467,7 @@ def get_logical_devices(): # try "fsutil" result = exec_command(["fsutil", "fsinfo", "drives"]).get("out", "") for device in re.findall(r"[A-Z]:\\", result): - items.append({"device": device, "name": None}) + items.append({"path": device, "name": None}) return items else: result = exec_command(["df"]).get("out") @@ -477,7 +477,7 @@ def get_logical_devices(): if not match: continue items.append({ - "device": match.group(1), + "path": match.group(1), "name": basename(match.group(1)) }) return items @@ -486,7 +486,7 @@ def get_logical_devices(): ### Backward compatibility for PIO Core <3.5 get_serialports = get_serial_ports get_logicaldisks = lambda: [{ - "disk": d['device'], + "disk": d['path'], "name": d['name'] } for d in get_logical_devices()] From ad08ed8d12d4a58e1620c61fdf94e7522bee5b57 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 27 Dec 2017 19:37:26 +0200 Subject: [PATCH 199/211] Improve support for partial package versions --- platformio/managers/lib.py | 29 +++++++----------- platformio/managers/package.py | 55 ++++++++++++++++++++++------------ tests/test_managers.py | 13 ++++---- 3 files changed, 52 insertions(+), 45 deletions(-) diff --git a/platformio/managers/lib.py b/platformio/managers/lib.py index 48cba9b5..ef00787b 100644 --- a/platformio/managers/lib.py +++ b/platformio/managers/lib.py @@ -21,7 +21,6 @@ from os.path import isdir, join import arrow import click -import semantic_version from platformio import app, commands, exception, util from platformio.managers.package import BasePkgManager @@ -153,8 +152,7 @@ class LibraryManager(BasePkgManager): ] return items - @staticmethod - def max_satisfying_repo_version(versions, requirements=None): + def max_satisfying_repo_version(self, versions, requirements=None): def _cmp_dates(datestr1, datestr2): date1 = arrow.get(datestr1) @@ -163,29 +161,22 @@ class LibraryManager(BasePkgManager): return 0 return -1 if date1 < date2 else 1 + semver_spec = self.parse_semver_spec( + requirements) if requirements else None item = None - reqspec = None - if requirements: - try: - reqspec = semantic_version.Spec(requirements) - except ValueError: - pass - for v in versions: - specver = None - try: - specver = semantic_version.Version(v['name'], partial=True) - except ValueError: - pass - if reqspec: - if not specver or specver not in reqspec: + for v in versions: + semver_new = self.parse_semver_version(v['name']) + if semver_spec: + if not semver_new or semver_new not in semver_spec: continue - if not item or semantic_version.Version( - item['name'], partial=True) < specver: + if not item or self.parse_semver_version( + item['name']) < semver_new: item = v elif requirements: if requirements == v['name']: return v + else: if not item or _cmp_dates(item['released'], v['released']) == -1: diff --git a/platformio/managers/package.py b/platformio/managers/package.py index e8e6dfdd..934a2e13 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -191,6 +191,27 @@ class PkgInstallerMixin(object): with FileUnpacker(source_path) as fu: return fu.unpack(dest_dir) + @staticmethod + def parse_semver_spec(value, raise_exception=False): + try: + return semantic_version.Spec(value) + except ValueError as e: + if raise_exception: + raise e + return None + + @staticmethod + def parse_semver_version(value, raise_exception=False): + try: + try: + return semantic_version.Version(value) + except ValueError: + return semantic_version.Version.coerce(value) + except ValueError as e: + if raise_exception: + raise e + return None + @staticmethod def get_install_dirname(manifest): name = re.sub(r"[^\da-z\_\-\. ]", "_", manifest['name'], flags=re.I) @@ -290,15 +311,15 @@ class PkgInstallerMixin(object): return manifest try: - if requirements and not semantic_version.Spec( - requirements).match( - semantic_version.Version( - manifest['version'], partial=True)): + if requirements and not self.parse_semver_spec( + requirements, raise_exception=True).match( + self.parse_semver_version( + manifest['version'], raise_exception=True)): continue - elif not best or (semantic_version.Version( - manifest['version'], partial=True) > - semantic_version.Version( - best['version'], partial=True)): + elif not best or (self.parse_semver_version( + manifest['version'], raise_exception=True) > + self.parse_semver_version( + best['version'], raise_exception=True)): best = manifest except ValueError: pass @@ -406,16 +427,10 @@ class PkgInstallerMixin(object): pkg_dir = join(self.package_dir, pkg_dirname) cur_manifest = self.load_manifest(pkg_dir) - tmp_semver = None + tmp_semver = self.parse_semver_version(tmp_manifest['version']) cur_semver = None - try: - tmp_semver = semantic_version.Version( - tmp_manifest['version'], partial=True) - if cur_manifest: - cur_semver = semantic_version.Version( - cur_manifest['version'], partial=True) - except ValueError: - pass + if cur_manifest: + cur_semver = self.parse_semver_version(cur_manifest['version']) # package should satisfy requirements if requirements: @@ -591,8 +606,10 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): up_to_date = False try: assert "__src_url" not in manifest - up_to_date = (semantic_version.Version.coerce(manifest['version']) - >= semantic_version.Version.coerce(latest)) + up_to_date = (self.parse_semver_version( + manifest['version'], raise_exception=True) >= + self.parse_semver_version( + latest, raise_exception=True)) except (AssertionError, ValueError): up_to_date = latest == manifest['version'] diff --git a/tests/test_managers.py b/tests/test_managers.py index 74bd652f..559c9d29 100644 --- a/tests/test_managers.py +++ b/tests/test_managers.py @@ -156,7 +156,7 @@ def test_install_packages(isolated_pio_home, tmpdir): dict(id=1, name="name_1", version="shasum"), dict(id=1, name="name_1", version="2.0.0"), dict(id=1, name="name_1", version="2.1.0"), - dict(id=1, name="name_1", version="1.2.0"), + dict(id=1, name="name_1", version="1.2"), dict(id=1, name="name_1", version="1.0.0"), dict(name="name_2", version="1.0.0"), dict(name="name_2", version="2.0.0", @@ -177,7 +177,7 @@ def test_install_packages(isolated_pio_home, tmpdir): assert len(pm.get_installed()) == len(packages) - 1 pkg_dirnames = [ - 'name_1_ID1', 'name_1_ID1@1.0.0', 'name_1_ID1@1.2.0', + 'name_1_ID1', 'name_1_ID1@1.0.0', 'name_1_ID1@1.2', 'name_1_ID1@2.0.0', 'name_1_ID1@shasum', 'name_2', 'name_2@src-177cbce1f0705580d17790fda1cc2ef5', 'name_2@src-f863b537ab00f4c7b5011fc44b120e1f' @@ -192,12 +192,11 @@ def test_get_package(isolated_pio_home): [("1", ), None], [("id=1", "shasum"), dict(id=1, name="name_1", version="shasum")], [("id=1", "*"), dict(id=1, name="name_1", version="2.1.0")], - [("id=1", "^1"), dict(id=1, name="name_1", version="1.2.0")], - [("id=1", "^1"), dict(id=1, name="name_1", version="1.2.0")], - [("name_1", "<2"), dict(id=1, name="name_1", version="1.2.0")], + [("id=1", "^1"), dict(id=1, name="name_1", version="1.2")], + [("id=1", "^1"), dict(id=1, name="name_1", version="1.2")], + [("name_1", "<2"), dict(id=1, name="name_1", version="1.2")], [("name_1", ">2"), None], - [("name_1", "2-0-0"), dict(id=1, name="name_1", version="2.1.0")], - [("name_1", "2-0-0"), dict(id=1, name="name_1", version="2.1.0")], + [("name_1", "2-0-0"), None], [("name_2", ), dict(name="name_2", version="4.0.0")], [("url_has_higher_priority", None, "git+https://github.com"), dict(name="name_2", version="2.0.0", From 5b7a0e69970b3abf36be1c1a21e89050c2413287 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 27 Dec 2017 19:57:57 +0200 Subject: [PATCH 200/211] Bump version to 3.5.0rc16 --- platformio/__init__.py | 2 +- platformio/managers/core.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 171302e6..d37b401b 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc15") +VERSION = (3, 5, "0rc16") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/managers/core.py b/platformio/managers/core.py index d75b063e..995634db 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -21,7 +21,7 @@ from platformio import __version__, exception, util from platformio.managers.package import PackageManager CORE_PACKAGES = { - "contrib-piohome": ">=0.5.3,<2", + "contrib-piohome": ">=0.6.0,<2", "contrib-pysite": ">=0.1.1,<2", "tool-pioplus": ">=0.12.1,<2", "tool-unity": "~1.20302.1", From 0516cd74e121215a46cd05e5306a401791aa9f69 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 27 Dec 2017 21:36:45 +0200 Subject: [PATCH 201/211] Check system compatibility for package --- Makefile | 5 ++++- platformio/managers/package.py | 15 +++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 51b3d166..0031d316 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,10 @@ isort: yapf: yapf --recursive --in-place platformio/ -before-commit: isort yapf lint +test: + py.test -v -s tests --ignore tests/test_examples.py --ignore tests/test_pkgmanifest.py + +before-commit: isort yapf lint test clean-docs: rm -rf docs/_build diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 934a2e13..cc3e444c 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -78,9 +78,15 @@ class PkgRepoMixin(object): PIO_VERSION = semantic_version.Version(util.pepver_to_semver(__version__)) @staticmethod - def max_satisfying_repo_version(versions, requirements=None): + def is_system_compatible(valid_systems): + if valid_systems in (None, "all", "*"): + return True + if not isinstance(valid_systems, list): + valid_systems = list([valid_systems]) + return util.get_systype() in valid_systems + + def max_satisfying_repo_version(self, versions, requirements=None): item = None - systype = util.get_systype() reqspec = None if requirements: try: @@ -89,8 +95,7 @@ class PkgRepoMixin(object): pass for v in versions: - if "system" in v and v['system'] not in ("all", "*") and \ - systype not in v['system']: + if not self.is_system_compatible(v.get("system")): continue if "platformio" in v.get("engines", {}): if PkgRepoMixin.PIO_VERSION not in semantic_version.Spec( @@ -305,6 +310,8 @@ class PkgInstallerMixin(object): continue elif not pkg_id and manifest['name'] != name: continue + elif not PkgRepoMixin.is_system_compatible(manifest.get("system")): + continue # strict version or VCS HASH if requirements and requirements == manifest['version']: From fc064aaf058a1761cdc15dd3e129b18581baf307 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 27 Dec 2017 21:38:03 +0200 Subject: [PATCH 202/211] Support the latest arrow package --- platformio/managers/core.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index 995634db..5b5529b0 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -22,7 +22,7 @@ from platformio.managers.package import PackageManager CORE_PACKAGES = { "contrib-piohome": ">=0.6.0,<2", - "contrib-pysite": ">=0.1.1,<2", + "contrib-pysite": ">=0.1.2,<2", "tool-pioplus": ">=0.12.1,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" diff --git a/setup.py b/setup.py index dceee7b2..df14dd1d 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ from platformio import (__author__, __description__, __email__, __license__, __title__, __url__, __version__) install_requires = [ - "arrow==0.10.0", + "arrow>=0.10.0,!=0.11.0", "bottle<0.13", "click>=5,<6", "colorama", From 62ee8066c2e0bd3c3c2f321a1b84c4b56a4378ef Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 27 Dec 2017 22:05:56 +0200 Subject: [PATCH 203/211] Handle incompatibility between PIO Core and PIO Core+ --- platformio/managers/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index 5b5529b0..42a6c775 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -75,7 +75,8 @@ class CorePackageManager(PackageManager): def get_core_package_dir(name): - assert name in CORE_PACKAGES + if name not in CORE_PACKAGES: + raise exception.PlatformioException("Please upgrade PIO Core") requirements = CORE_PACKAGES[name] pm = CorePackageManager() pkg_dir = pm.get_package_dir(name, requirements) From 012cb85e31525c925cac48013a92635b8cff58d5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Dec 2017 00:19:17 +0200 Subject: [PATCH 204/211] Allow libraries with the same folder name --- platformio/builder/tools/piolib.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index f1f4c33c..a7838c76 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -17,6 +17,7 @@ from __future__ import absolute_import +import hashlib import os import sys from os.path import (basename, commonprefix, dirname, isdir, isfile, join, @@ -89,6 +90,7 @@ class LibBuilderBase(object): CLASSIC_SCANNER = SCons.Scanner.C.CScanner() ADVANCED_SCANNER = SCons.Scanner.C.CScanner(advanced=True) PARSE_SRC_BY_H_NAME = True + _INCLUDE_DIRS_CACHE = None def __init__(self, env, path, manifest=None, verbose=False): @@ -163,7 +165,9 @@ class LibBuilderBase(object): @property def build_dir(self): - return join("$BUILD_DIR", "lib", basename(self.path)) + return join("$BUILD_DIR", + "lib%s" % hashlib.sha1(self.path).hexdigest()[:3], + basename(self.path)) @property def build_flags(self): From f13bf35dbdaa1876e6183bf33f42d52276b3dbbb Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Dec 2017 01:11:54 +0200 Subject: [PATCH 205/211] Bump version to 3.5.0rc17 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index d37b401b..e9650708 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc16") +VERSION = (3, 5, "0rc17") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From ac4b4855215c8b6e9d60fd36ac7ed2e10e7dc5b5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Dec 2017 14:27:08 +0200 Subject: [PATCH 206/211] Fix issue with non-ascii path when printing LDF Tree in verbose mode --- platformio/builder/tools/piolib.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index a7838c76..8973bdfb 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -805,9 +805,12 @@ def BuildProjectLibraries(env): title = "<%s>" % lb.name if lb.version: title += " v%s" % lb.version + sys.stdout.write("%s|-- %s" % (margin, title)) if int(ARGUMENTS.get("PIOVERBOSE", 0)): - title += " (%s)" % lb.path - print "%s|-- %s" % (margin, title) + sys.stdout.write(" (") + sys.stdout.write(lb.path) + sys.stdout.write(")") + sys.stdout.write("\n") if lb.depbuilders: print_deps_tree(lb, level + 1) From 9c9a40a53140865a7ccaf2553b2b3ae9529d9d69 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Dec 2017 15:01:18 +0200 Subject: [PATCH 207/211] Add GitHub to PING_INTERNET_IPS list --- platformio/util.py | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio/util.py b/platformio/util.py index a1c16b95..410bcff7 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -656,6 +656,7 @@ def get_api_result(url, params=None, data=None, auth=None, cache_valid=None): PING_INTERNET_IPS = [ + "192.30.253.113", # github.com "159.122.18.156", # dl.bintray.com "193.222.52.25" # dl.platformio.org ] From 2315b089098032b83e1b178e633779e844add8d5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Dec 2017 16:51:18 +0200 Subject: [PATCH 208/211] PIO Home docs --- HISTORY.rst | 18 +++++++++++++++++- docs | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index e7a9c16f..bbb2080f 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,7 +7,23 @@ PlatformIO 3.0 3.5.0 (2017-??-??) ~~~~~~~~~~~~~~~~~~ -* PIO Home +* `PlatformIO Home `__ - + interact with PlatformIO ecosystem using modern and cross-platform GUI: + + - Library Manager: + + * Search for new libraries in PlatformIO Registry + * "1-click" library installation, per-project libraries, extra storages + * List installed libraries in multiple storages + * List built-in libraries (by frameworks) + * Updates for installed libraries + * Multiple examples, trending libraries, and more. + + - PlatformIO Projects + - PIO Account + - Development platforms, frameworks and board explorer + - Device Manager: serial, logical, and multicast DNS services + * Integration with `Jenkins CI `_ * New `include `__ folder for project's header files diff --git a/docs b/docs index 0403f687..c76ccaf3 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 0403f687d6bca4f40a3e8ed2cfc2c635fc198516 +Subproject commit c76ccaf33786e93392c80decdb457794ac234380 From 34e9063dddba0b0bb37f679d42a6552699490389 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Dec 2017 16:58:15 +0200 Subject: [PATCH 209/211] Use "paged" links for docs --- HISTORY.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index bbb2080f..2a7764c5 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,7 +7,7 @@ PlatformIO 3.0 3.5.0 (2017-??-??) ~~~~~~~~~~~~~~~~~~ -* `PlatformIO Home `__ - +* `PlatformIO Home `__ - interact with PlatformIO ecosystem using modern and cross-platform GUI: - Library Manager: @@ -24,12 +24,12 @@ PlatformIO 3.0 - Development platforms, frameworks and board explorer - Device Manager: serial, logical, and multicast DNS services -* Integration with `Jenkins CI `_ -* New `include `__ +* Integration with `Jenkins CI `_ +* New `include `__ folder for project's header files (`issue #1107 `_) * Depend on development platform using VSC URL (Git, Mercurial and Subversion) - instead of a name in `Project Configuration File "platformio.ini" `__. + instead of a name in `Project Configuration File "platformio.ini" `__. Drop support for ``*_stage`` dev/platform names (use VCS URL instead). * Reinstall/redownload package with a new ``-f, --force`` option for `platformio lib install `__ @@ -39,7 +39,7 @@ PlatformIO 3.0 * Handle missed dependencies and provide a solution based on PlatformIO Library Registry (`issue #781 `_) -* New setting `projects_dir `__ +* New setting `projects_dir `__ that allows to override a default PIO Home Projects location (`issue #1161 `_) @@ -55,7 +55,7 @@ PlatformIO 3.0 - Added option to configure library `Compatible Mode `__ using `library.json `__ -* New options for `platformio device list `__ +* New options for `platformio device list `__ command: - ``--serial`` list available serial ports (default) From 12e4318de7087b41c811fc8589ef789ab9250c6e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Dec 2017 17:15:34 +0200 Subject: [PATCH 210/211] Don't follow redirects when checking internet connection --- platformio/util.py | 3 ++- tests/test_misc.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/platformio/util.py b/platformio/util.py index 410bcff7..a040380f 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -669,7 +669,8 @@ def _internet_on(): for ip in PING_INTERNET_IPS: try: if os.getenv("HTTP_PROXY", os.getenv("HTTPS_PROXY")): - requests.get("http://%s" % ip, timeout=timeout) + requests.get( + "http://%s" % ip, allow_redirects=False, timeout=timeout) else: socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((ip, 80)) diff --git a/tests/test_misc.py b/tests/test_misc.py index 5d569b5b..e8121c99 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -19,4 +19,4 @@ from platformio import util def test_ping_internet_ips(): for ip in util.PING_INTERNET_IPS: - requests.get("http://%s" % ip, timeout=2) + requests.get("http://%s" % ip, allow_redirects=False, timeout=2) From 755ade05c65c5180ca94eaaf89dbc65d7136fd5c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Dec 2017 17:25:49 +0200 Subject: [PATCH 211/211] Bump version to 3.5.0 (issue #1260, issue #781, issue #778, issue #463, issue #1236, issue #1235, issue #953, issue #1118, issue #1107, issue #1196, issue #1179, issue #1161, issue #1126, issue #104, issue #1033, issue #1034, issue #1175, issue #1173, issue #1155, issue #1188, issue #1111, issue #1153, issue #1150, issue #1145, issue #1139, issue #1137, issue #1170, issue #1157, issue #1102, issue #1105, issue #1140, issue #1154, issue #1066, issue #1038, issue #1054, issue #1055, issue #1061, issue #1017) --- HISTORY.rst | 2 +- platformio/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 2a7764c5..666336b3 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,7 +4,7 @@ Release Notes PlatformIO 3.0 -------------- -3.5.0 (2017-??-??) +3.5.0 (2017-12-28) ~~~~~~~~~~~~~~~~~~ * `PlatformIO Home `__ - diff --git a/platformio/__init__.py b/platformio/__init__.py index e9650708..33de06c8 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 5, "0rc17") +VERSION = (3, 5, 0) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio"