Allow upgrading to the latest develop version if no new stable release using "platformio upgrade"

This commit is contained in:
Ivan Kravets
2016-01-23 21:45:08 +02:00
parent 870b306b86
commit 59a97bff3d

View File

@ -34,8 +34,17 @@ def cli():
click.secho("Please wait while upgrading PlatformIO ...",
fg="yellow")
to_develop = False
try:
from pkg_resources import parse_version
to_develop = parse_version(last) < parse_version(__version__)
except ImportError:
pass
cmds = (
["pip", "install", "--upgrade", "platformio"],
["pip", "install", "--upgrade",
"https://github.com/platformio/platformio/archive/develop.zip"
if to_develop else "platformio"],
["platformio", "--version"]
)
@ -53,10 +62,11 @@ def cli():
r = util.exec_command(cmd)
assert r['returncode'] == 0
assert last in r['out'].strip()
assert "version" in r['out']
actual_version = r['out'].strip().split("version", 1)[1].strip()
click.secho(
"PlatformIO has been successfully upgraded to %s" % last,
fg="green")
"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")