6
def relocate_file(old_location, new_location):
8
keyring 0.8 changes the default location for storage of
9
file-based keyring locations. This function is invoked to move
10
files stored in the old location to the new location.
12
TODO: remove this function for keyring 1.0.
14
if not os.path.exists(old_location):
15
# nothing to do; no legacy file found
18
if os.path.exists(new_location):
19
print >> sys.stderr, ("Password file found in legacy "
20
"location\n %(old_location)s\nand new location\n"
21
" %(new_location)s\nOld location will be ignored."
25
# ensure the storage path exists
26
if not os.path.isdir(os.path.dirname(new_location)):
27
os.makedirs(os.path.dirname(new_location))
28
os.chmod(os.path.dirname(new_location),
29
stat.S_IWRITE | stat.S_IREAD | stat.S_IEXEC)
30
shutil.move(old_location, new_location)