def cli(dev): if not dev and __version__ == get_latest_version(): return click.secho( "You're up-to-date!\nPlatformIO %s is currently the " "newest version available." % __version__, fg="green") click.secho("Please wait while upgrading PlatformIO ...", fg="yellow") # kill all PIO Home servers, they block `pioplus` binary shutdown_piohome_servers() to_develop = dev or not all(c.isdigit() for c in __version__ if c != ".") cmds = (["pip", "install", "--upgrade", get_pip_package(to_develop)], ["platformio", "--version"]) cmd = None r = {} try: for cmd in cmds: cmd = [get_pythonexe_path(), "-m"] + cmd r = exec_command(cmd) # try pip with disabled cache if r['returncode'] != 0 and cmd[2] == "pip": cmd.insert(3, "--no-cache-dir") r = exec_command(cmd) assert r['returncode'] == 0 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, fg="green") click.echo("Release notes: ", nl=False) click.secho("https://docs.platformio.org/en/latest/history.html", fg="cyan") except Exception as e: # pylint: disable=broad-except if not r: raise exception.UpgradeError("\n".join([str(cmd), str(e)])) permission_errors = ("permission denied", "not permitted") if (any(m in r['err'].lower() for m in permission_errors) and not WINDOWS): click.secho(""" ----------------- Permission denied ----------------- You need the `sudo` permission to install Python packages. Try > sudo pip install -U platformio WARNING! Don't use `sudo` for the rest PlatformIO commands. """, fg="yellow", err=True) raise exception.ReturnErrorCode(1) raise exception.UpgradeError("\n".join([str(cmd), r['out'], r['err']])) return True
def cli(): last = get_latest_version() if __version__ == last: return click.secho( "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") cmds = ( ["pip", "install", "--upgrade", "platformio"], ["platformio", "--version"] ) cmd = None r = None try: for cmd in cmds: r = None r = util.exec_command(cmd) # try pip with disabled cache if r['returncode'] != 0 and cmd[0] == "pip": r = util.exec_command(["pip", "--no-cache-dir"] + cmd[1:]) assert r['returncode'] == 0 assert last in r['out'].strip() click.secho( "PlatformIO has been successfully upgraded to %s" % last, fg="green") click.echo("Release notes: ", nl=False) click.secho("http://docs.platformio.org/en/latest/history.html", fg="cyan") except Exception as e: # pylint: disable=W0703 if not r: raise exception.UpgradeError( "\n".join([str(cmd), str(e)])) permission_errors = ( "permission denied", "not permitted" ) if (any([m in r['err'].lower() for m in permission_errors]) and "windows" not in util.get_systype()): click.secho(""" ----------------- Permission denied ----------------- You need the `sudo` permission to install Python packages. Try > sudo pip install -U platformio WARNING! Don't use `sudo` for the rest PlatformIO commands. """, fg="yellow", err=True) raise exception.ReturnErrorCode() else: raise exception.UpgradeError( "\n".join([str(cmd), r['out'], r['err']]))
def after_upgrade(ctx): last_version = app.get_state_item("last_version", "0.0.0") if last_version == __version__: return if last_version == "0.0.0": app.set_state_item("last_version", __version__) else: click.secho("Please wait while upgrading PlatformIO ...", fg="yellow") clean_cache() u = Upgrader(last_version, __version__) if u.run(ctx): app.set_state_item("last_version", __version__) # update development platforms pm = PlatformManager() for manifest in pm.get_installed(): # pm.update(manifest['name'], "^" + manifest['version']) pm.update(manifest['name']) # update PlatformIO Plus tool if installed pioplus_update() click.secho("PlatformIO has been successfully upgraded to %s!\n" % __version__, fg="green") telemetry.on_event(category="Auto", action="Upgrade", label="%s > %s" % (last_version, __version__)) else: raise exception.UpgradeError("Auto upgrading...") click.echo("") # PlatformIO banner terminal_width, _ = click.get_terminal_size() click.echo("*" * terminal_width) click.echo("If you like %s, please:" % (click.style("PlatformIO", fg="cyan"))) click.echo("- %s us on Twitter to stay up-to-date " "on the latest project news > %s" % (click.style("follow", fg="cyan"), click.style("https://twitter.com/PlatformIO_Org", fg="cyan"))) click.echo( "- %s it on GitHub > %s" % (click.style("star", fg="cyan"), click.style("https://github.com/platformio/platformio", fg="cyan"))) if not getenv("PLATFORMIO_IDE"): click.echo( "- %s PlatformIO IDE for IoT development > %s" % (click.style("try", fg="cyan"), click.style("http://platformio.org/platformio-ide", fg="cyan"))) if not util.is_ci(): click.echo("- %s us with PlatformIO Plus > %s" % (click.style("support", fg="cyan"), click.style("https://pioplus.com", fg="cyan"))) click.echo("*" * terminal_width) click.echo("")
def after_upgrade(ctx): last_version = app.get_state_item("last_version", "0.0.0") if last_version == __version__: return terminal_width, _ = click.get_terminal_size() # promotion click.echo("") click.echo("*" * terminal_width) click.echo("If you like %s, please:" % (click.style("PlatformIO", fg="cyan"))) click.echo("- %s us on Twitter to stay up-to-date " "on the latest project news > %s" % (click.style("follow", fg="cyan"), click.style("https://twitter.com/PlatformIO_Org", fg="cyan"))) click.echo( "- %s it on GitHub > %s" % (click.style("star", fg="cyan"), click.style("https://github.com/platformio/platformio", fg="cyan"))) if not getenv("PLATFORMIO_IDE"): click.echo("- %s PlatformIO IDE for IoT development > %s" % (click.style("try", fg="cyan"), click.style("http://platformio.org/#!/platformio-ide", fg="cyan"))) if not util.is_ci(): click.echo("- %s to keep PlatformIO alive! > %s" % (click.style("donate", fg="cyan"), click.style("http://platformio.org/#!/donate", fg="cyan"))) click.echo("*" * terminal_width) click.echo("") if last_version == "0.0.0": app.set_state_item("last_version", __version__) return click.secho("Please wait while upgrading PlatformIO ...", fg="yellow") u = Upgrader(last_version, __version__) if u.run(ctx): app.set_state_item("last_version", __version__) ctx.invoke(cmd_platforms_update) click.secho("PlatformIO has been successfully upgraded to %s!\n" % __version__, fg="green") telemetry.on_event(category="Auto", action="Upgrade", label="%s > %s" % (last_version, __version__)) else: raise exception.UpgradeError("Auto upgrading...") click.echo("")
def after_upgrade(ctx): terminal_width, _ = click.get_terminal_size() last_version = app.get_state_item("last_version", "0.0.0") if last_version == __version__: return if last_version == "0.0.0": app.set_state_item("last_version", __version__) elif semantic_version.Version.coerce(util.pepver_to_semver( last_version)) > semantic_version.Version.coerce( util.pepver_to_semver(__version__)): click.secho("*" * terminal_width, fg="yellow") click.secho( "Obsolete PIO Core v%s is used (previous was %s)" % (__version__, last_version), fg="yellow") click.secho( "Please remove multiple PIO Cores from a system:", fg="yellow") click.secho( "http://docs.platformio.org/page/faq.html" "#multiple-pio-cores-in-a-system", fg="cyan") click.secho("*" * terminal_width, fg="yellow") return else: click.secho("Please wait while upgrading PlatformIO...", fg="yellow") app.clean_cache() # Update PlatformIO's Core packages update_core_packages(silent=True) u = Upgrader(last_version, __version__) if u.run(ctx): app.set_state_item("last_version", __version__) click.secho( "PlatformIO has been successfully upgraded to %s!\n" % __version__, fg="green") telemetry.on_event( category="Auto", action="Upgrade", label="%s > %s" % (last_version, __version__)) else: raise exception.UpgradeError("Auto upgrading...") click.echo("") # PlatformIO banner click.echo("*" * terminal_width) click.echo("If you like %s, please:" % (click.style("PlatformIO", fg="cyan"))) click.echo("- %s us on Twitter to stay up-to-date " "on the latest project news > %s" % (click.style("follow", fg="cyan"), click.style("https://twitter.com/PlatformIO_Org", fg="cyan"))) click.echo( "- %s it on GitHub > %s" % (click.style("star", fg="cyan"), click.style("https://github.com/platformio/platformio", fg="cyan"))) if not getenv("PLATFORMIO_IDE"): click.echo( "- %s PlatformIO IDE for IoT development > %s" % (click.style("try", fg="cyan"), click.style("http://platformio.org/platformio-ide", fg="cyan"))) if not util.is_ci(): click.echo("- %s us with PlatformIO Plus > %s" % (click.style("support", fg="cyan"), click.style("https://pioplus.com", fg="cyan"))) click.echo("*" * terminal_width) click.echo("")
def cli(): # Update PlatformIO's Core packages update_core_packages(silent=True) latest = get_latest_version() if __version__ == latest: return click.secho( "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") to_develop = not all([c.isdigit() for c in latest if c != "."]) cmds = ([ "pip", "install", "--upgrade", "https://github.com/platformio/platformio-core/archive/develop.zip" if to_develop else "platformio" ], ["platformio", "--version"]) cmd = None r = None try: for cmd in cmds: cmd = [util.get_pythonexe_path(), "-m"] + cmd r = None r = util.exec_command(cmd) # try pip with disabled cache if r['returncode'] != 0 and cmd[2] == "pip": cmd.insert(3, "--no-cache-dir") r = util.exec_command(cmd) assert r['returncode'] == 0 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, fg="green") click.echo("Release notes: ", nl=False) click.secho("http://docs.platformio.org/en/latest/history.html", fg="cyan") except Exception as e: # pylint: disable=broad-except if not r: raise exception.UpgradeError("\n".join([str(cmd), str(e)])) permission_errors = ("permission denied", "not permitted") if (any([m in r['err'].lower() for m in permission_errors]) and "windows" not in util.get_systype()): click.secho(""" ----------------- Permission denied ----------------- You need the `sudo` permission to install Python packages. Try > sudo pip install -U platformio WARNING! Don't use `sudo` for the rest PlatformIO commands. """, fg="yellow", err=True) raise exception.ReturnErrorCode(1) else: raise exception.UpgradeError("\n".join( [str(cmd), r['out'], r['err']]))