[config] softfail when config cannot be written

This commit is contained in:
Max Zwiessele 2016-04-08 11:38:46 +01:00
parent 86457baeeb
commit 4ee3799773

View file

@ -176,7 +176,8 @@ home = os.getenv('HOME') or os.getenv('USERPROFILE')
user_file = os.path.join(home,'.config', 'GPy', 'user.cfg') user_file = os.path.join(home,'.config', 'GPy', 'user.cfg')
print("") print("")
if not os.path.exists(user_file): try:
if not os.path.exists(user_file):
# Does an old config exist? # Does an old config exist?
old_user_file = os.path.join(home,'.gpy_user.cfg') old_user_file = os.path.join(home,'.gpy_user.cfg')
if os.path.exists(old_user_file): if os.path.exists(old_user_file):
@ -194,5 +195,7 @@ if not os.path.exists(user_file):
with open(local_file, 'r') as l: with open(local_file, 'r') as l:
tmp = l.read() tmp = l.read()
f.write(tmp) f.write(tmp)
else: else:
print("GPy: User configuration file at location {}".format(user_file)) print("GPy: User configuration file at location {}".format(user_file))
except:
print("GPy: Could not write user configuration file {}".format(user_file))