diff --git a/platformio/__main__.py b/platformio/__main__.py index b437e760..299ee5eb 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -103,6 +103,19 @@ def main(): error_str += str(e) else: error_str += format_exc() + + error_str += """ +============================================================ + +An unexpected error occurred. Further steps: + +* Verify that you have the latest version of PlatformIO using + `platformio upgrade` command +* Report this problem to the developers + https://github.com/platformio/platformio/issues + +============================================================ +""" click.secho(error_str, fg="red", err=True) return 1 return 0 diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index 72c21737..883f2c9f 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -135,7 +135,7 @@ def lib_install(ctx, libid, version): except AssertionError: raise exception.LibInstallDependencyError(str(item)) - except exception.LibAlreadyInstalledError: + except exception.LibAlreadyInstalled: click.secho("Already installed", fg="yellow") diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 438e5dc2..761644bb 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -56,9 +56,9 @@ def cli(): click.echo("Release notes: ", nl=False) click.secho("http://docs.platformio.org/en/latest/history.html", fg="cyan") - except (OSError, AssertionError) as e: + except Exception as e: # pylint: disable=W0703 if not r: - raise exception.PlatformioUpgradeError( + raise exception.UpgradeError( "\n".join([str(cmd), str(e)])) if ("Permission denied" in r['err'] and "windows" not in util.get_systype()): @@ -74,7 +74,7 @@ WARNING! Don't use `sudo` for the rest PlatformIO commands. """, fg="yellow", err=True) raise exception.ReturnErrorCode() else: - raise exception.PlatformioUpgradeError( + raise exception.UpgradeError( "\n".join([str(cmd), r['out'], r['err']])) diff --git a/platformio/exception.py b/platformio/exception.py index e0378083..74491f70 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -149,11 +149,11 @@ class APIRequestError(PlatformioException): MESSAGE = "[API] %s" -class LibAlreadyInstalledError(PlatformioException): +class LibAlreadyInstalled(PlatformioException): pass -class LibNotInstalledError(PlatformioException): +class LibNotInstalled(PlatformioException): MESSAGE = "Library #%d has not been installed yet" @@ -183,11 +183,6 @@ class InvalidSettingValue(PlatformioException): MESSAGE = "Invalid value '%s' for the setting '%s'" -class UpgraderFailed(PlatformioException): - - MESSAGE = "An error occurred while upgrading PlatformIO" - - class CIBuildEnvsEmpty(PlatformioException): MESSAGE = "Can't find PlatformIO build environments.\n"\ @@ -195,20 +190,20 @@ class CIBuildEnvsEmpty(PlatformioException): "predefined environments using `--project-conf` option" -class SConsNotInstalled(PlatformioException): +class SConsNotInstalledError(PlatformioException): MESSAGE = "The PlatformIO and `scons` aren't installed properly. "\ "More details in FAQ/Troubleshooting section: "\ "http://docs.platformio.org/en/latest/faq.html" -class PlatformioUpgradeError(PlatformioException): +class UpgradeError(PlatformioException): - MESSAGE = "%s \n\n"\ - "1. Please report this issue here: "\ - "https://github.com/platformio/platformio/issues \n"\ - "2. Try different installation/upgrading steps: "\ - "http://docs.platformio.org/en/latest/installation.html" + MESSAGE = """%s + +* Try different installation/upgrading steps: + http://docs.platformio.org/en/latest/installation.html +""" class CygwinEnvDetected(PlatformioException): diff --git a/platformio/libmanager.py b/platformio/libmanager.py index 0dbe0df0..cd0b57fa 100644 --- a/platformio/libmanager.py +++ b/platformio/libmanager.py @@ -21,7 +21,7 @@ from tempfile import gettempdir from platformio import telemetry, util from platformio.downloader import FileDownloader -from platformio.exception import LibAlreadyInstalledError, LibNotInstalledError +from platformio.exception import LibAlreadyInstalled, LibNotInstalled from platformio.unpacker import FileUnpacker @@ -73,17 +73,17 @@ class LibraryManager(object): for item in self.get_installed().values(): if "id" in item and item['id'] == id_: return item - raise LibNotInstalledError(id_) + raise LibNotInstalled(id_) def is_installed(self, id_): try: return int(self.get_info(id_)['id']) == id_ - except LibNotInstalledError: + except LibNotInstalled: return False def install(self, id_, version=None): if self.is_installed(id_): - raise LibAlreadyInstalledError() + raise LibAlreadyInstalled() dlinfo = util.get_api_result( "/lib/download/" + str(id_), @@ -120,4 +120,4 @@ class LibraryManager(object): label="#%d %s" % (id_, item['name']) ) return True - raise LibNotInstalledError(id_) + raise LibNotInstalled(id_) diff --git a/platformio/maintenance.py b/platformio/maintenance.py index a60e90d9..dc5a2861 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -145,11 +145,6 @@ def after_upgrade(ctx): click.style("give", fg="cyan"), click.style("https://github.com/platformio/platformio", fg="cyan") )) - click.echo("- %s for the new features/issues on Bountysource > %s" % ( - click.style("vote", fg="cyan"), - click.style("https://www.bountysource.com/teams/platformio/issues", - fg="cyan") - )) click.echo("*" * terminal_width) click.echo("") @@ -171,7 +166,7 @@ def after_upgrade(ctx): telemetry.on_event(category="Auto", action="Upgrade", label="%s > %s" % (last_version, __version__)) else: - raise exception.UpgraderFailed() + raise exception.UpgradeError("Auto upgrading...") click.echo("") diff --git a/platformio/platforms/base.py b/platformio/platforms/base.py index 2fcaf8cd..c4488dd1 100644 --- a/platformio/platforms/base.py +++ b/platformio/platforms/base.py @@ -395,7 +395,7 @@ class BasePlatform(object): stderr=util.AsyncPipe(self.on_run_err) ) except (OSError, AssertionError): - raise exception.SConsNotInstalled() + raise exception.SConsNotInstalledError() assert "returncode" in result # if self._found_error: diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 17dccb38..43a501dd 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -291,7 +291,10 @@ def on_exception(e): return mp = MeasurementProtocol() mp['exd'] = "%s: %s" % (type(e).__name__, e) - mp['exf'] = int(not isinstance(e, exception.PlatformioException)) + mp['exf'] = int(any([ + not isinstance(e, exception.PlatformioException), + "Error" in e.__class__.__name__ + ])) mp.send("exception")