From 63a6fe9133a4752a56d00c1a1938669442267c72 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 27 Oct 2020 21:07:02 +0200 Subject: [PATCH] Improved "core.call" RPC for PlatformIO Home // Resolve #3671 --- HISTORY.rst | 1 + platformio/__init__.py | 2 +- platformio/commands/home/rpc/handlers/piocore.py | 5 +++-- platformio/commands/home/rpc/handlers/project.py | 12 +++++++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 2df28579..d42543d6 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,6 +12,7 @@ PlatformIO Core 5 ~~~~~~~~~~~~~~~~~~ - Automatically build PlatformIO Core extra Python dependencies on a host machine if they are missed in the registry (`issue #3700 `_) +- Improved "core.call" RPC for PlatformIO Home (`issue #3671 `_) - Fixed a "PermissionError: [WinError 5]" on Windows when external repository is used with `lib_deps `__ option (`issue #3664 `_) - Fixed a "KeyError: 'versions'" when dependency does not exist in the registry (`issue #3666 `_) - Fixed an issue with GCC linker when "native" dev-platform is used in pair with library dependencies (`issue #3669 `_) diff --git a/platformio/__init__.py b/platformio/__init__.py index f9ebb52c..bcf64951 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -47,7 +47,7 @@ __pioremote_endpoint__ = "ssl:host=remote.platformio.org:port=4413" __default_requests_timeout__ = (10, None) # (connect, read) __core_packages__ = { - "contrib-piohome": "~3.3.0", + "contrib-piohome": "~3.3.1", "contrib-pysite": "~2.%d%d.0" % (sys.version_info.major, sys.version_info.minor), "tool-unity": "~1.20500.0", "tool-scons": "~2.20501.7" if sys.version_info.major == 2 else "~4.40001.0", diff --git a/platformio/commands/home/rpc/handlers/piocore.py b/platformio/commands/home/rpc/handlers/piocore.py index 00adf5b6..81b773c0 100644 --- a/platformio/commands/home/rpc/handlers/piocore.py +++ b/platformio/commands/home/rpc/handlers/piocore.py @@ -95,10 +95,11 @@ class PIOCoreRPC(object): else: args[i] = str(arg) + options = options or {} to_json = "--json-output" in args try: - if args and args[0] == "remote": + if options.get("force_subprocess"): result = yield PIOCoreRPC._call_subprocess(args, options) defer.returnValue(PIOCoreRPC._process_result(result, to_json)) else: @@ -117,7 +118,7 @@ class PIOCoreRPC(object): @staticmethod def _call_inline(args, options): PIOCoreRPC.setup_multithreading_std_streams() - cwd = (options or {}).get("cwd") or os.getcwd() + cwd = options.get("cwd") or os.getcwd() def _thread_task(): with fs.cd(cwd): diff --git a/platformio/commands/home/rpc/handlers/project.py b/platformio/commands/home/rpc/handlers/project.py index 2db966b6..eb9cd237 100644 --- a/platformio/commands/home/rpc/handlers/project.py +++ b/platformio/commands/home/rpc/handlers/project.py @@ -198,7 +198,9 @@ class ProjectRPC(object): and state["storage"]["coreCaller"] in ProjectGenerator.get_supported_ides() ): args.extend(["--ide", state["storage"]["coreCaller"]]) - d = PIOCoreRPC.call(args, options={"cwd": project_dir}) + d = PIOCoreRPC.call( + args, options={"cwd": project_dir, "force_subprocess": True} + ) d.addCallback(self._generate_project_main, project_dir, framework) return d @@ -291,7 +293,9 @@ class ProjectRPC(object): and state["storage"]["coreCaller"] in ProjectGenerator.get_supported_ides() ): args.extend(["--ide", state["storage"]["coreCaller"]]) - d = PIOCoreRPC.call(args, options={"cwd": project_dir}) + d = PIOCoreRPC.call( + args, options={"cwd": project_dir, "force_subprocess": True} + ) d.addCallback(self._finalize_arduino_import, project_dir, arduino_project_dir) return d @@ -324,6 +328,8 @@ class ProjectRPC(object): and state["storage"]["coreCaller"] in ProjectGenerator.get_supported_ides() ): args.extend(["--ide", state["storage"]["coreCaller"]]) - d = PIOCoreRPC.call(args, options={"cwd": new_project_dir}) + d = PIOCoreRPC.call( + args, options={"cwd": new_project_dir, "force_subprocess": True} + ) d.addCallback(lambda _: new_project_dir) return d