Handle WindowsError when can't remove .pioenvs directory

This commit is contained in:
Ivan Kravets
2015-10-06 17:06:47 +01:00
parent 52b98dd159
commit 1c9dc2ba3d
2 changed files with 30 additions and 30 deletions

View File

@ -45,7 +45,10 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914
# clean obsolete .pioenvs dir # clean obsolete .pioenvs dir
if not disable_auto_clean: if not disable_auto_clean:
_clean_pioenvs_dir() try:
_clean_pioenvs_dir(util.get_pioenvs_dir())
except Exception:
raise exception.CleanPioenvsDirError(util.get_pioenvs_dir())
results = [] results = []
for section in config.sections(): for section in config.sections():
@ -224,8 +227,7 @@ def _autoinstall_libs(ctx, libids_list):
ctx.invoke(cmd_lib_install, libid=not_intalled_libs) ctx.invoke(cmd_lib_install, libid=not_intalled_libs)
def _clean_pioenvs_dir(): def _clean_pioenvs_dir(pioenvs_dir):
pioenvs_dir = util.get_pioenvs_dir()
structhash_file = join(pioenvs_dir, "structure.hash") structhash_file = join(pioenvs_dir, "structure.hash")
proj_hash = calculate_project_hash() proj_hash = calculate_project_hash()

View File

@ -33,14 +33,14 @@ class UnknownPlatform(PlatformioException):
class PlatformNotInstalledYet(PlatformioException): class PlatformNotInstalledYet(PlatformioException):
MESSAGE = ("The platform '%s' has not been installed yet. " MESSAGE = "The platform '%s' has not been installed yet. "\
"Use `platformio platforms install` command") "Use `platformio platforms install` command"
class UnknownCLICommand(PlatformioException): class UnknownCLICommand(PlatformioException):
MESSAGE = ("Unknown command '%s'. Please use `platformio --help`" MESSAGE = "Unknown command '%s'. Please use `platformio --help`"\
" to see all available commands") " to see all available commands"
class UnknownBoard(PlatformioException): class UnknownBoard(PlatformioException):
@ -75,14 +75,14 @@ class FDUnrecognizedStatusCode(PlatformioException):
class FDSizeMismatch(PlatformioException): class FDSizeMismatch(PlatformioException):
MESSAGE = ("The size (%d bytes) of downloaded file '%s' " MESSAGE = "The size (%d bytes) of downloaded file '%s' "\
"is not equal to remote size (%d bytes)") "is not equal to remote size (%d bytes)"
class FDSHASumMismatch(PlatformioException): class FDSHASumMismatch(PlatformioException):
MESSAGE = ("The 'sha1' sum '%s' of downloaded file '%s' " MESSAGE = "The 'sha1' sum '%s' of downloaded file '%s' "\
"is not equal to remote '%s'") "is not equal to remote '%s'"
class NotPlatformProject(PlatformioException): class NotPlatformProject(PlatformioException):
@ -117,6 +117,12 @@ class UnknownEnvNames(PlatformioException):
MESSAGE = "Unknown environment names '%s'. Valid names are '%s'" MESSAGE = "Unknown environment names '%s'. Valid names are '%s'"
class CleanPioenvsDirError(PlatformioException):
MESSAGE = "Can not remove temporary directory `%s`. "\
"Please remove it manually"
class GetSerialPortsError(PlatformioException): class GetSerialPortsError(PlatformioException):
MESSAGE = "No implementation for your platform ('%s') available" MESSAGE = "No implementation for your platform ('%s') available"
@ -124,7 +130,7 @@ class GetSerialPortsError(PlatformioException):
class GetLatestVersionError(PlatformioException): class GetLatestVersionError(PlatformioException):
MESSAGE = "Can't retrieve the latest PlatformIO version" MESSAGE = "Can not retrieve the latest PlatformIO version"
class APIRequestError(PlatformioException): class APIRequestError(PlatformioException):
@ -173,36 +179,28 @@ class UpgraderFailed(PlatformioException):
class CIBuildEnvsEmpty(PlatformioException): class CIBuildEnvsEmpty(PlatformioException):
MESSAGE = ( MESSAGE = "Can't find PlatformIO build environments.\n"\
"Can't find PlatformIO build environments.\nPlease specify `--board` " "Please specify `--board` or path to `platformio.ini` with "\
"or path to `platformio.ini` with predefined environments using " "predefined environments using `--project-conf` option"
"`--project-conf` option"
)
class SConsNotInstalled(PlatformioException): class SConsNotInstalled(PlatformioException):
MESSAGE = ( MESSAGE = "The PlatformIO and `scons` aren't installed properly. "\
"The PlatformIO and `scons` aren't installed properly. " "More details in FAQ/Troubleshooting section: "\
"More details in FAQ/Troubleshooting section: "
"http://docs.platformio.org/en/latest/faq.html" "http://docs.platformio.org/en/latest/faq.html"
)
class PlatformioUpgradeError(PlatformioException): class PlatformioUpgradeError(PlatformioException):
MESSAGE = ( MESSAGE = "%s \n\n"\
"%s \n\n" "1. Please report this issue here: "\
"1. Please report this issue here: " "https://github.com/platformio/platformio/issues \n"\
"https://github.com/platformio/platformio/issues \n" "2. Try different installation/upgrading steps: "\
"2. Try different installation/upgrading steps: "
"http://docs.platformio.org/en/latest/installation.html" "http://docs.platformio.org/en/latest/installation.html"
)
class CygwinEnvDetected(PlatformioException): class CygwinEnvDetected(PlatformioException):
MESSAGE = ( MESSAGE = "PlatformIO does not work within Cygwin environment. "\
"PlatformIO does not work within Cygwin environment. "
"Use native Terminal instead." "Use native Terminal instead."
)