summaryrefslogtreecommitdiff
path: root/cerbero
diff options
context:
space:
mode:
authorAndoni Morales Alastruey <ylatuya@gmail.com>2013-06-06 16:41:52 +0200
committerAndoni Morales Alastruey <ylatuya@gmail.com>2013-06-06 16:46:14 +0200
commitf43d14726f6af346ef08802ea27d02e916c3d0d6 (patch)
tree2b789904626e759775000e3bb746e12b43dea04e /cerbero
parent1266897721ceade09169bc6671348fb62ff27a65 (diff)
wipe: fix weird windows error removing directories
Diffstat (limited to 'cerbero')
-rw-r--r--cerbero/commands/wipe.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/cerbero/commands/wipe.py b/cerbero/commands/wipe.py
index bf9d1fe..d2ea051 100644
--- a/cerbero/commands/wipe.py
+++ b/cerbero/commands/wipe.py
@@ -26,13 +26,6 @@ from cerbero.utils import _, N_, shell, ArgparseArgument
import cerbero.utils.messages as m
-def _onerror(func, path, exc_info):
- if not os.access(path, os.W_OK):
- os.chmod(path, stat.S_IWUSR)
- func(path)
- else:
- raise
-
class Wipe(Command):
doc = N_('Wipes everything to restore the build system')
name = 'wipe'
@@ -76,6 +69,17 @@ class Wipe(Command):
self.wipe(to_remove)
def wipe(self, paths):
+
+ def _onerror(func, path, exc_info):
+ if not os.access(path, os.W_OK):
+ os.chmod(path, stat.S_IWUSR)
+ func(path)
+ # Handle "Directory is not empty" errors
+ elif exc_info[1][0] == 145:
+ shutil.rmtree(path, onerror=_onerror)
+ else:
+ raise
+
for path in paths:
m.action(_("Removing path: %s") % path)
if not os.path.exists(path):