os.remove(filename)
except OSError:
pass
- os.rename(temp_file, filename)
+ Retry(os.rename, temp_file, filename)
def WriteFile(data, filename):
for f in files:
dstfile = os.path.join(dstroot, f)
if os.path.isfile(dstfile):
- os.remove(dstfile)
+ Retry(os.remove, dstfile)
shutil.copy2(os.path.join(root, f), dstfile)
MoveAndMergeDirTree(source_item, destination_item)
elif os.path.isfile(destination_item) and os.path.isfile(source_item):
# Overwrite the file if they are both files.
- os.unlink(destination_item)
+ Retry(os.unlink, destination_item)
Retry(os.rename, source_item, destination_item)
else:
raise OSError('Cannot move directory tree, mismatching types.'
Retry(os.rename, source_item, destination_item)
# Remove the directory once all the contents have been moved
- os.rmdir(src_dir)
+ Retry(os.rmdir, src_dir)
def Retry(op, *args):