From 3507290a20ff118c55d450774dbab0eb1290dede Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 25 Oct 2018 13:44:41 +0300 Subject: [PATCH] Shutdown PIO Home server before updating `tool-pioplus`; Update `tool-pioplus` to 1.4.11 --- platformio/commands/home.py | 11 ----------- platformio/commands/upgrade.py | 4 ++-- platformio/managers/core.py | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/platformio/commands/home.py b/platformio/commands/home.py index ae797781..cd6b86f6 100644 --- a/platformio/commands/home.py +++ b/platformio/commands/home.py @@ -15,7 +15,6 @@ import sys import click -import requests from platformio.managers.core import pioplus_call @@ -30,13 +29,3 @@ 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 47b43304..98430483 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -20,7 +20,7 @@ import click import requests from platformio import VERSION, __version__, exception, util -from platformio.commands.home import shutdown_servers +from platformio.managers.core import shutdown_piohome_servers @click.command( @@ -36,7 +36,7 @@ def cli(dev): click.secho("Please wait while upgrading PlatformIO ...", fg="yellow") # kill all PIO Home servers, they block `pioplus` binary - shutdown_servers() + shutdown_piohome_servers() to_develop = dev or not all(c.isdigit() for c in __version__ if c != ".") cmds = (["pip", "install", "--upgrade", diff --git a/platformio/managers/core.py b/platformio/managers/core.py index ef185cf9..3da9e4ec 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -17,13 +17,15 @@ import subprocess import sys from os.path import dirname, join +import requests + from platformio import __version__, exception, util from platformio.managers.package import PackageManager CORE_PACKAGES = { "contrib-piohome": "^1.0.2", "contrib-pysite": ">=0.3.2,<2", - "tool-pioplus": "^1.4.5", + "tool-pioplus": "^1.4.11", "tool-unity": "~1.20403.0", "tool-scons": "~2.20501.4" } @@ -92,10 +94,22 @@ def update_core_packages(only_check=False, silent=False): if not pkg_dir: continue if not silent or pm.outdated(pkg_dir, requirements): + if name == "tool-pioplus" and not only_check: + shutdown_piohome_servers() pm.update(name, requirements, only_check=only_check) return True +def shutdown_piohome_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 + + def pioplus_call(args, **kwargs): if "windows" in util.get_systype() and sys.version_info < (2, 7, 6): raise exception.PlatformioException(