default profile fix

This commit is contained in:
ingvar1995 2016-09-21 21:14:53 +03:00
parent 97ce2b9ceb
commit 9fe9ba4743
2 changed files with 16 additions and 9 deletions

View File

@ -160,6 +160,7 @@ class History:
db.close()
def unlock_db(self):
print('Unlocking db...')
connection = dbapi2.connect(self._name)
connection.commit()
connection.close()

View File

@ -49,9 +49,9 @@ class Settings(dict, Singleton):
@staticmethod
def get_auto_profile():
path = Settings.get_default_path() + 'toxygen.json'
if os.path.isfile(path):
with open(path) as fl:
p = Settings.get_default_path() + 'toxygen.json'
if os.path.isfile(p):
with open(p) as fl:
data = fl.read()
auto = json.loads(data)
if 'path' in auto and 'name' in auto:
@ -61,9 +61,12 @@ class Settings(dict, Singleton):
@staticmethod
def set_auto_profile(path, name):
p = Settings.get_default_path() + 'toxygen.json'
with open(p) as fl:
data = fl.read()
data = json.loads(data)
if os.path.isfile(p):
with open(p) as fl:
data = fl.read()
data = json.loads(data)
else:
data = {}
data['path'] = str(path)
data['name'] = str(name)
with open(p, 'w') as fl:
@ -72,9 +75,12 @@ class Settings(dict, Singleton):
@staticmethod
def reset_auto_profile():
p = Settings.get_default_path() + 'toxygen.json'
with open(p) as fl:
data = fl.read()
data = json.loads(data)
if os.path.isfile(p):
with open(p) as fl:
data = fl.read()
data = json.loads(data)
else:
data = {}
if 'path' in data:
del data['path']
del data['name']