Display more clean error on users.json/sites.json load error

This commit is contained in:
shortcutme 2019-08-07 14:11:30 +02:00
parent b6e1559a80
commit 6cd18bbf04
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
2 changed files with 14 additions and 2 deletions

View File

@ -33,7 +33,13 @@ class SiteManager(object):
address_found = []
added = 0
# Load new adresses
for address, settings in json.load(open("%s/sites.json" % config.data_dir)).items():
try:
json_path = "%s/sites.json" % config.data_dir
data = json.load(open(json_path))
except Exception as err:
raise Exception("Unable to load %s: %s" % (json_path, err))
for address, settings in data.items():
if address not in self.sites:
if os.path.isfile("%s/%s/content.json" % (config.data_dir, address)):
# Root content.json exists, try load site

View File

@ -24,7 +24,13 @@ class UserManager(object):
added = 0
s = time.time()
# Load new users
for master_address, data in list(json.load(open("%s/users.json" % config.data_dir)).items()):
try:
json_path = "%s/users.json" % config.data_dir
data = json.load(open(json_path))
except Exception as err:
raise Exception("Unable to load %s: %s" % (json_path, err))
for master_address, data in list(data.items()):
if master_address not in self.users:
user = User(master_address, data=data)
self.users[master_address] = user