Show More
@@ -586,6 +586,17 b' def rename(src, dst):' | |||||
586 | shutil.copy(src, dst) |
|
586 | shutil.copy(src, dst) | |
587 | os.remove(src) |
|
587 | os.remove(src) | |
588 |
|
588 | |||
|
589 | def makecleanable(path): | |||
|
590 | """Try to fix directory permission recursively so that the entire tree | |||
|
591 | can be deleted""" | |||
|
592 | for dirpath, dirnames, _filenames in os.walk(path, topdown=True): | |||
|
593 | for d in dirnames: | |||
|
594 | p = os.path.join(dirpath, d) | |||
|
595 | try: | |||
|
596 | os.chmod(p, os.stat(p).st_mode & 0o777 | 0o700) # chmod u+rwx | |||
|
597 | except OSError: | |||
|
598 | pass | |||
|
599 | ||||
589 | _unified_diff = difflib.unified_diff |
|
600 | _unified_diff = difflib.unified_diff | |
590 | if PYTHON3: |
|
601 | if PYTHON3: | |
591 | import functools |
|
602 | import functools | |
@@ -952,7 +963,13 b' class Test(unittest.TestCase):' | |||||
952 | (self._testtmp.decode('utf-8'), |
|
963 | (self._testtmp.decode('utf-8'), | |
953 | self._threadtmp.decode('utf-8'))) |
|
964 | self._threadtmp.decode('utf-8'))) | |
954 | else: |
|
965 | else: | |
955 | shutil.rmtree(self._testtmp, True) |
|
966 | try: | |
|
967 | shutil.rmtree(self._testtmp) | |||
|
968 | except OSError: | |||
|
969 | # unreadable directory may be left in $TESTTMP; fix permission | |||
|
970 | # and try again | |||
|
971 | makecleanable(self._testtmp) | |||
|
972 | shutil.rmtree(self._testtmp, True) | |||
956 | shutil.rmtree(self._threadtmp, True) |
|
973 | shutil.rmtree(self._threadtmp, True) | |
957 |
|
974 | |||
958 | if self._usechg: |
|
975 | if self._usechg: |
General Comments 0
You need to be logged in to leave comments.
Login now