mirror of
https://git.codelinaro.org/clo/tools/repo.git
synced 2025-08-06 13:51:36 +08:00
Replace all os.remove calls
os.remove raises an exception when deleting read-only files on Windows. Replace all calls with calls to platform_utils.remove, which deals with deals with that issue. Change-Id: I4dc9e0c9a36b4238880520c69f5075eca40f3e66
This commit is contained in:
@ -244,6 +244,23 @@ def rename(src, dst):
|
||||
os.rename(src, dst)
|
||||
|
||||
|
||||
def remove(path):
|
||||
"""Remove (delete) the file path. This is a replacement for os.remove, but
|
||||
allows deleting read-only files on Windows.
|
||||
"""
|
||||
if isWindows():
|
||||
try:
|
||||
os.remove(path)
|
||||
except OSError as e:
|
||||
if e.errno == errno.EACCES:
|
||||
os.chmod(path, stat.S_IWRITE)
|
||||
os.remove(path)
|
||||
else:
|
||||
raise
|
||||
else:
|
||||
os.remove(path)
|
||||
|
||||
|
||||
def islink(path):
|
||||
"""Test whether a path is a symbolic link.
|
||||
|
||||
|
Reference in New Issue
Block a user