forked from platformio/platformio-core
Terminate PIO Home servers when upgrade PIO Core // Issue #1132
This commit is contained in:
@ -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
|
||||
|
@ -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,9 +34,12 @@ 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")
|
||||
|
||||
# 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",
|
||||
@ -60,8 +64,7 @@ def cli():
|
||||
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,
|
||||
"PlatformIO has been successfully upgraded to %s" % actual_version,
|
||||
fg="green")
|
||||
click.echo("Release notes: ", nl=False)
|
||||
click.secho(
|
||||
|
Reference in New Issue
Block a user