MCPcopy Create free account
hub / github.com/gitless-vcs/gitless / rmtree

Function rmtree

gitless/tests/utils.py:67–82  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

65
66
67def rmtree(path):
68 # On Windows, running shutil.rmtree on a folder that contains read-only
69 # files throws errors. To workaround this, if removing a path fails, we make
70 # the path writable and then try again
71 def onerror(func, path, unused_exc_info): # error handler for rmtree
72 if not os.access(path, os.W_OK):
73 os.chmod(path, stat.S_IWUSR)
74 func(path)
75 else:
76 # Swallow errors for now (on Windows there seems to be something weird
77 # going on and we can't remove the temp directory even after all files
78 # in it have been successfully removed)
79 pass
80
81 shutil.rmtree(path, onerror=onerror)
82 logging.debug('Removed dir {0}'.format(path))
83
84
85def write_file(fp, contents=''):

Callers 1

tearDownMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected