MCPcopy Create free account
hub / github.com/Windscribe/Desktop-App / RenameFile

Function RenameFile

tools/base/utils.py:175–193  ·  view source on GitHub ↗
(srcname, dstname)

Source from the content-addressed store, hash-verified

173
174
175def RenameFile(srcname, dstname):
176 msg.Verbose("RenameFile: \"{}\" to \"{}\"".format(srcname, dstname))
177 usrcname = MakeUnicodePath(srcname)
178 if not os.path.exists(usrcname):
179 msg.Verbose("File doesn't exist")
180 return True
181 udstname = MakeUnicodePath(dstname)
182 if os.path.exists(udstname):
183 RemoveFile(dstname)
184 last_error = None
185 for _ in range(_OS_RETRY_COUNT):
186 try:
187 os.rename(usrcname, udstname)
188 return True
189 except EnvironmentError as e:
190 last_error = e
191 time.sleep(1)
192 raise IOError("Can't rename file \"{}\" to \"{}\"!\nLast error: {}".format(
193 srcname, dstname, last_error))
194
195
196def RemoveAllFiles(sourcedir, filemask):

Callers

nothing calls this directly

Calls 3

MakeUnicodePathFunction · 0.85
RemoveFileFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected