diff --git a/platformio/__main__.py b/platformio/__main__.py index d4da091c..85cbd401 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -118,7 +118,7 @@ def main(): try: configure() cli(None, None, None) - except Exception as e: # pylint: disable=W0703 + except Exception as e: # pylint: disable=broad-except if not isinstance(e, exception.ReturnErrorCode): maintenance.on_platformio_exception(e) error_str = "Error: " diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index df9fc0ee..1faa95ef 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -66,7 +66,7 @@ def cli(): 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 + 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") diff --git a/platformio/util.py b/platformio/util.py index e9dc86c5..4a4027f3 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -627,8 +627,13 @@ def pepver_to_semver(pepver): def rmtree_(path): def _onerror(_, name, __): - os.chmod(name, stat.S_IWRITE) - os.remove(name) + try: + os.chmod(name, stat.S_IWRITE) + os.remove(name) + except Exception as e: # pylint: disable=broad-except + click.secho( + "Please manually remove file `%s`" % name, fg="red", err=True) + raise e return rmtree(path, onerror=_onerror)