From d278f8f21555475c60cecad1be69969b570c8358 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 11 Jul 2022 13:36:01 +0300 Subject: [PATCH 01/15] CI: Run deployment on the master branch --- .github/workflows/deployment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 629a06d5..9d652a7d 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -3,6 +3,7 @@ name: Deployment on: push: branches: + - "master" - "release/**" jobs: From f070399cadff4502c8ac496d5e5a56c2331d9c33 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 11 Jul 2022 13:39:17 +0300 Subject: [PATCH 02/15] Bump version to 6.1.2a1 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 0e360ce3..67e233eb 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (6, 1, 1) +VERSION = (6, 1, "2a1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From dcc02c3e14dfa782014d46b23798d36342e5593a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 12 Jul 2022 22:06:29 +0300 Subject: [PATCH 03/15] Revert "Use generic MISSING helper" This reverts commit 31a24e1652b7633890037ac9c489e9930250b49d. --- platformio/builder/tools/piolib.py | 12 +++++++----- platformio/debug/config/base.py | 7 ++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index bd9e319a..83e04f69 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -30,7 +30,7 @@ from SCons.Script import DefaultEnvironment # pylint: disable=import-error from platformio import exception, fs from platformio.builder.tools import platformio as piotool -from platformio.compat import IS_WINDOWS, MISSING, hashlib_encode_data, string_types +from platformio.compat import IS_WINDOWS, hashlib_encode_data, string_types from platformio.http import HTTPClientError, InternetIsOffline from platformio.package.exception import ( MissingPackageManifestError, @@ -576,10 +576,11 @@ class ArduinoLibBuilder(LibBuilderBase): # pylint: disable=no-member if not self._manifest.get("dependencies"): return LibBuilderBase.lib_ldf_mode.fget(self) + missing = object() global_value = self.env.GetProjectConfig().getraw( - "env:" + self.env["PIOENV"], "lib_ldf_mode", MISSING + "env:" + self.env["PIOENV"], "lib_ldf_mode", missing ) - if global_value != MISSING: + if global_value != missing: return LibBuilderBase.lib_ldf_mode.fget(self) # automatically enable C++ Preprocessing in runtime # (Arduino IDE has this behavior) @@ -831,10 +832,11 @@ class PlatformIOLibBuilder(LibBuilderBase): @property def lib_archive(self): + missing = object() global_value = self.env.GetProjectConfig().getraw( - "env:" + self.env["PIOENV"], "lib_archive", MISSING + "env:" + self.env["PIOENV"], "lib_archive", missing ) - if global_value != MISSING: + if global_value != missing: return self.env.GetProjectConfig().get( "env:" + self.env["PIOENV"], "lib_archive" ) diff --git a/platformio/debug/config/base.py b/platformio/debug/config/base.py index 7e966cc5..a5867340 100644 --- a/platformio/debug/config/base.py +++ b/platformio/debug/config/base.py @@ -16,7 +16,7 @@ import json import os from platformio import fs, proc, util -from platformio.compat import MISSING, string_types +from platformio.compat import string_types from platformio.debug.exception import DebugInvalidOptionsError from platformio.project.config import ProjectConfig from platformio.project.helpers import load_build_metadata @@ -96,8 +96,9 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes @property def init_break(self): - result = self.env_options.get("debug_init_break", MISSING) - if result != MISSING: + missed = object() + result = self.env_options.get("debug_init_break", missed) + if result != missed: return result result = None if not result: From 83bb6611b940db6d6dbfbca1090a1ace83494edb Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 12 Jul 2022 22:21:09 +0300 Subject: [PATCH 04/15] Fixed a regression bug when libArchive option declared in the library.json manifest was ignored // Resolve # --- HISTORY.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 75db03f0..3be873ee 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -13,6 +13,11 @@ PlatformIO Core 6 **A professional collaborative platform for declarative, safety-critical, and test-driven embedded development.** +6.1.2 (2022-07-??) +~~~~~~~~~~~~~~~~~~ + +* Fixed a regression bug when `libArchive `__ option declared in the `library.json `__ manifest was ignored (`issue #4351 `_) + 6.1.1 (2022-07-11) ~~~~~~~~~~~~~~~~~~ From 5282124664bb8bd51ed61562f1c5939cda7fae37 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 12 Jul 2022 22:21:42 +0300 Subject: [PATCH 05/15] Bump version to 6.1.2a2 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 67e233eb..bc41394a 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (6, 1, "2a1") +VERSION = (6, 1, "2a2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 6f8f2511c26abd4e382d769d8491f137b91154d3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Jul 2022 14:31:28 +0300 Subject: [PATCH 06/15] Look for another mirror on any requests.exceptions.RequestException --- platformio/http.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/platformio/http.py b/platformio/http.py index ff88a85b..e9ef3546 100644 --- a/platformio/http.py +++ b/platformio/http.py @@ -13,7 +13,6 @@ # limitations under the License. import json -import math import os import socket from urllib.parse import urljoin @@ -63,9 +62,10 @@ class EndpointSessionIterator: endpoints = [endpoints] self.endpoints = endpoints self.endpoints_iter = iter(endpoints) + # https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html self.retry = Retry( - total=math.ceil(6 / len(self.endpoints)), - backoff_factor=1, + total=3, + backoff_factor=1, # [0, 2 4] secs # method_whitelist=list(Retry.DEFAULT_METHOD_WHITELIST) + ["POST"], status_forcelist=[413, 429, 500, 502, 503, 504], ) @@ -129,10 +129,7 @@ class HTTPClient: while True: try: return getattr(self._session, method)(path, **kwargs) - except ( - requests.exceptions.ConnectionError, - requests.exceptions.Timeout, - ) as exc: + except requests.exceptions.RequestException as exc: try: self._next_session() except Exception as exc2: From 4278574450f6e9b93a130590439b27fc96b54ea8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Jul 2022 14:46:40 +0300 Subject: [PATCH 07/15] =?UTF-8?q?Fixed=20an=20issue=20when=20the=20"pio=20?= =?UTF-8?q?pkg=20publish"=20command=20didn=E2=80=99t=20work=20with=20Pytho?= =?UTF-8?q?n=203.6=20//=20#4352?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HISTORY.rst | 1 + platformio/compat.py | 9 +++++++++ platformio/package/commands/publish.py | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 3be873ee..51bd288e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,6 +17,7 @@ PlatformIO Core 6 ~~~~~~~~~~~~~~~~~~ * Fixed a regression bug when `libArchive `__ option declared in the `library.json `__ manifest was ignored (`issue #4351 `_) +* Fixed an issue when the `pio pkg publish `__ command didn't work with Python 3.6 (`issue #4352 `_) 6.1.1 (2022-07-11) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/compat.py b/platformio/compat.py index 43eb98dd..cdce3939 100644 --- a/platformio/compat.py +++ b/platformio/compat.py @@ -41,6 +41,15 @@ def is_bytes(x): return isinstance(x, (bytes, memoryview, bytearray)) +def isascii(text): + if sys.version_info >= (3, 7): + return text.isascii() + for c in text or "": + if ord(c) > 127: + return False + return True + + def ci_strings_are_equal(a, b): if a == b: return True diff --git a/platformio/package/commands/publish.py b/platformio/package/commands/publish.py index 8d282fa0..58230eef 100644 --- a/platformio/package/commands/publish.py +++ b/platformio/package/commands/publish.py @@ -22,6 +22,7 @@ from tabulate import tabulate from platformio import fs from platformio.account.client import AccountClient +from platformio.compat import isascii from platformio.exception import UserSideException from platformio.package.manifest.parser import ManifestParserFactory from platformio.package.manifest.schema import ManifestSchema @@ -155,7 +156,7 @@ def package_publish_cmd( # pylint: disable=too-many-arguments, too-many-locals def check_archive_file_names(archive_path): with tarfile.open(archive_path, mode="r:gz") as tf: for name in tf.getnames(): - if not name.isascii(): + if not isascii(name) or not name.isprintable(): click.secho( f"Warning! The `{name}` file contains non-ASCII chars and can " "lead to the unpacking issues on a user machine", From a31a7f2b061ee11ccb591ec8a55e5c7e13039115 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Jul 2022 18:26:21 +0300 Subject: [PATCH 08/15] Improved detection of Windows architecture // Resolve #4353 --- HISTORY.rst | 1 + platformio/util.py | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 51bd288e..72d5fa89 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -16,6 +16,7 @@ PlatformIO Core 6 6.1.2 (2022-07-??) ~~~~~~~~~~~~~~~~~~ +* Improved detection of Windows architecture (`issue #4353 `_) * Fixed a regression bug when `libArchive `__ option declared in the `library.json `__ manifest was ignored (`issue #4351 `_) * Fixed an issue when the `pio pkg publish `__ command didn't work with Python 3.6 (`issue #4352 `_) diff --git a/platformio/util.py b/platformio/util.py index f235c2ee..f6800b4f 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -139,11 +139,14 @@ def singleton(cls): def get_systype(): - type_ = platform.system().lower() + system = platform.system().lower() arch = platform.machine().lower() - if type_ == "windows" and "x86" in arch: - arch = "amd64" if "64" in arch else "x86" - return "%s_%s" % (type_, arch) if arch else type_ + if system == "windows": + if not arch: # issue #4353 + arch = "x86_" + platform.architecture()[0] + if "x86" in arch: + arch = "amd64" if "64" in arch else "x86" + return "%s_%s" % (system, arch) if arch else system def pioversion_to_intstr(): From bc325ab2cc4d0ed48b3b297f5df60b80e206ae94 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Jul 2022 18:32:04 +0300 Subject: [PATCH 09/15] Increase number of http retries to 5 --- platformio/http.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/http.py b/platformio/http.py index e9ef3546..cf686070 100644 --- a/platformio/http.py +++ b/platformio/http.py @@ -64,8 +64,8 @@ class EndpointSessionIterator: self.endpoints_iter = iter(endpoints) # https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html self.retry = Retry( - total=3, - backoff_factor=1, # [0, 2 4] secs + total=5, + backoff_factor=1, # [0, 2, 4, 8, 16] secs # method_whitelist=list(Retry.DEFAULT_METHOD_WHITELIST) + ["POST"], status_forcelist=[413, 429, 500, 502, 503, 504], ) From 10ff4ae77aa07f8ff8cba4cf85ae2754ccb14c5d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Jul 2022 14:45:16 +0300 Subject: [PATCH 10/15] Docs: Improve docs for advanced scripting --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index f4accb77..91e68ce5 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit f4accb77c85da86b6bd60670f6e02719db22235c +Subproject commit 91e68ce5829c1aa4a4b6eebc7bd94645b7f01fde From 842679c32b52d3e63c6f778e59ff4887f981c5c2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Jul 2022 14:45:31 +0300 Subject: [PATCH 11/15] Export a "PIO_UNIT_TESTING" macro to the project source files and dependent libraries in the Unit Testing mode --- HISTORY.rst | 1 + platformio/builder/tools/piolib.py | 4 ++++ platformio/builder/tools/piotest.py | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 72d5fa89..e659e93d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -16,6 +16,7 @@ PlatformIO Core 6 6.1.2 (2022-07-??) ~~~~~~~~~~~~~~~~~~ +* Export a ``PIO_UNIT_TESTING`` macro to the project source files and dependent libraries in the |UNITTESTING| mode * Improved detection of Windows architecture (`issue #4353 `_) * Fixed a regression bug when `libArchive `__ option declared in the `library.json `__ manifest was ignored (`issue #4351 `_) * Fixed an issue when the `pio pkg publish `__ command didn't work with Python 3.6 (`issue #4352 `_) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 83e04f69..d375347f 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -145,6 +145,10 @@ class LibBuilderBase: self._circular_deps = [] self._processed_search_files = [] + # pass a macro to the projenv + libs + if "test" in env.GetBuildType(): + self.env.Append(CPPDEFINES=["PIO_UNIT_TESTING"]) + # reset source filter, could be overridden with extra script self.env["SRC_FILTER"] = "" diff --git a/platformio/builder/tools/piotest.py b/platformio/builder/tools/piotest.py index 08d475d2..07886efb 100644 --- a/platformio/builder/tools/piotest.py +++ b/platformio/builder/tools/piotest.py @@ -23,7 +23,7 @@ from platformio.test.runners.factory import TestRunnerFactory def ConfigureTestTarget(env): env.Append( - CPPDEFINES=["UNIT_TEST", "PIO_UNIT_TESTING"], + CPPDEFINES=["UNIT_TEST"], # deprecated, use PIO_UNIT_TESTING PIOTEST_SRC_FILTER=[f"+<*.{ext}>" for ext in piotool.SRC_BUILD_EXT], ) env.Prepend(CPPPATH=["$PROJECT_TEST_DIR"]) From bedbae6311c7067ed1fa7c29664eb8d96bd96e38 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Jul 2022 14:45:55 +0300 Subject: [PATCH 12/15] Bump version to 6.1.2a3 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index bc41394a..f449d27c 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (6, 1, "2a2") +VERSION = (6, 1, "2a3") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 3a70c902a9fa99ebf6c8c2570ac45931ecf5271a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 18 Jul 2022 14:57:22 +0300 Subject: [PATCH 13/15] Docs: Improve docs for the test suite filter/ignore options --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 91e68ce5..044b6d24 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 91e68ce5829c1aa4a4b6eebc7bd94645b7f01fde +Subproject commit 044b6d24a6e9392a2137b5ab7d2e2f95882773fd From 73089b3cb0025972ce024b48c9ca018bc229b23f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 18 Jul 2022 17:24:38 +0300 Subject: [PATCH 14/15] Warn about unknown device monitor filters // Resolve #4362 --- HISTORY.rst | 1 + platformio/device/monitor/command.py | 13 ++++++++++++- platformio/device/monitor/terminal.py | 6 +++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index e659e93d..e05d6706 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,6 +18,7 @@ PlatformIO Core 6 * Export a ``PIO_UNIT_TESTING`` macro to the project source files and dependent libraries in the |UNITTESTING| mode * Improved detection of Windows architecture (`issue #4353 `_) +* Warn about unknown `device monitor filters `__ (`issue #4362 `_) * Fixed a regression bug when `libArchive `__ option declared in the `library.json `__ manifest was ignored (`issue #4351 `_) * Fixed an issue when the `pio pkg publish `__ command didn't work with Python 3.6 (`issue #4352 `_) diff --git a/platformio/device/monitor/command.py b/platformio/device/monitor/command.py index 0a484eee..11a1afdf 100644 --- a/platformio/device/monitor/command.py +++ b/platformio/device/monitor/command.py @@ -20,7 +20,7 @@ import click from platformio import exception, fs from platformio.device.finder import find_serial_port from platformio.device.monitor.filters.base import register_filters -from platformio.device.monitor.terminal import start_terminal +from platformio.device.monitor.terminal import get_available_filters, start_terminal from platformio.platform.factory import PlatformFactory from platformio.project.config import ProjectConfig from platformio.project.exception import NotPlatformIOProjectError @@ -138,6 +138,17 @@ def device_monitor_cmd(**options): "--exit-char can not be the same as --menu-char" ) + # check for unknown filters + known_filters = set(get_available_filters()) + unknown_filters = set(options["filters"]) - known_filters + if unknown_filters: + options["filters"] = list(known_filters & set(options["filters"])) + click.secho( + ("Warning! Skipping unknown filters `%s`. Known filters are `%s`") + % (", ".join(unknown_filters), ", ".join(sorted(known_filters))), + fg="yellow", + ) + start_terminal(options) diff --git a/platformio/device/monitor/terminal.py b/platformio/device/monitor/terminal.py index 38c18390..bec825e9 100644 --- a/platformio/device/monitor/terminal.py +++ b/platformio/device/monitor/terminal.py @@ -41,6 +41,10 @@ class Terminal(miniterm.Miniterm): self.pio_unexpected_exception = exc +def get_available_filters(): + return sorted(miniterm.TRANSFORMATIONS.keys()) + + def start_terminal(options): retries = 0 is_port_valid = False @@ -116,7 +120,7 @@ def print_terminal_settings(terminal): ) click.echo( "--- Available filters and text transformations: %s" - % ", ".join(sorted(miniterm.TRANSFORMATIONS.keys())) + % ", ".join(get_available_filters()) ) click.echo("--- More details at https://bit.ly/pio-monitor-filters") click.echo( From cd4f5541ac2523a3f46021bb3aa218087e2c1e20 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 18 Jul 2022 17:26:10 +0300 Subject: [PATCH 15/15] Bump version to 6.1.2 --- HISTORY.rst | 2 +- docs | 2 +- platformio/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index e05d6706..db6444eb 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -13,7 +13,7 @@ PlatformIO Core 6 **A professional collaborative platform for declarative, safety-critical, and test-driven embedded development.** -6.1.2 (2022-07-??) +6.1.2 (2022-07-18) ~~~~~~~~~~~~~~~~~~ * Export a ``PIO_UNIT_TESTING`` macro to the project source files and dependent libraries in the |UNITTESTING| mode diff --git a/docs b/docs index 044b6d24..0a58185b 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 044b6d24a6e9392a2137b5ab7d2e2f95882773fd +Subproject commit 0a58185b4a983db4478cfba41307b02f22461543 diff --git a/platformio/__init__.py b/platformio/__init__.py index f449d27c..594635e6 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (6, 1, "2a3") +VERSION = (6, 1, 2) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio"