This commit is contained in:
Kai Wansart 2018-02-02 17:52:51 +01:00
parent 720040bbb1
commit f9205fdc55

View File

@ -38,8 +38,8 @@ class Config(object):
data = None data = None
if(type == "settings"): if(type == "settings"):
print("Reading 'settings.json'") print("Reading 'settings.json'")
if(os.path.isfile(path + "config/settings.json")): if(os.path.isfile(path + "/config/settings.json")):
with open(path + 'config/settings.json', encoding='utf-8') as data_file: with open(path + '/config/settings.json', encoding='utf-8') as data_file:
try: try:
data = json.loads(data_file.read()) data = json.loads(data_file.read())
except: except:
@ -52,8 +52,8 @@ class Config(object):
self.writeConfig("settings", data) self.writeConfig("settings", data)
else: else:
print("Reading 'devices.json'") print("Reading 'devices.json'")
if(os.path.isfile(path + "config/devices.json")): if(os.path.isfile(path + "/config/devices.json")):
with open(path + 'config/devices.json', encoding='utf-8') as data_file: with open(path + '/config/devices.json', encoding='utf-8') as data_file:
try: try:
data = json.loads(data_file.read()) data = json.loads(data_file.read())
except: except:
@ -73,11 +73,11 @@ class Config(object):
print(path) print(path)
if(type == "settings"): if(type == "settings"):
print("Writing 'settings.json'") print("Writing 'settings.json'")
with open(path + 'config/settings.json', 'w') as outfile: with open(path + '/config/settings.json', 'w') as outfile:
json.dump(data, outfile, indent=4) json.dump(data, outfile, indent=4)
print("Settings written") print("Settings written")
else: else:
print("Writing 'devices.json'") print("Writing 'devices.json'")
with open(path + 'config/devices.json', 'w') as outfile: with open(path + '/config/devices.json', 'w') as outfile:
json.dump(data, outfile, indent=4) json.dump(data, outfile, indent=4)
print("Devices written") print("Devices written")