From affb47b82e56babc595c99d5ea486100b5c5674d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 3 Dec 2014 20:15:52 +0200 Subject: [PATCH] Ask user to install platform when it hasn't been installed yet --- HISTORY.rst | 7 +++++-- platformio/commands/run.py | 5 ++++- platformio/commands/show.py | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 8c43e569..27f43c59 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,10 +4,13 @@ Release History 0.9.1 (?) --------- -* Fixed "*OSError: [Errno 2] No such file or directory*" for +* Ask user to install platform (when it hasn't been installed yet) within + `platformio run `_ + and `platformio show `_ commands +* Improved main `documentation `_ +* Fixed "*OSError: [Errno 2] No such file or directory*" within `platformio run `_ command when PlatformIO isn't installed properly -* Improved main `documentation `_ * Fixed example for `Eclipse IDE with Tiva board `_ (`issue #32 `_) diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 400a6f3a..476e05c6 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -59,7 +59,10 @@ def cli(environment, target, upload_port): telemetry.on_run_environment(config.items(section), envtargets) - p = PlatformFactory().newPlatform(config.get(section, "platform")) + if (platform not in PlatformFactory.get_platforms(installed=True) and + click.confirm("The platform '%s' has not been installed yet. " + "Would you like to install it now?" % platform)): + ctx.invoke(cmd_install, platforms=[platform]) result = p.run(variables, envtargets) secho(result['out'], fg="green") secho(result['err'], diff --git a/platformio/commands/show.py b/platformio/commands/show.py index 5d2a9d83..48f1b800 100644 --- a/platformio/commands/show.py +++ b/platformio/commands/show.py @@ -18,7 +18,11 @@ def cli(platform): installed=True).keys() if platform not in installed_platforms: - raise PlatformNotInstalledYet(platform) + if click.confirm("The platform '%s' has not been installed yet. " + "Would you like to install it now?" % platform): + ctx.invoke(cmd_install, platforms=[platform]) + else: + raise PlatformNotInstalledYet(platform) p = PlatformFactory().newPlatform(platform) echo("{name:<20} - {info}".format(name=style(p.get_name(), fg="cyan"),