Ignore missing sites.json gracefully
This commit is contained in:
parent
9d8be57025
commit
76d1b14eaf
2 changed files with 9 additions and 4 deletions
|
@ -87,7 +87,11 @@ class Site(object):
|
||||||
# Load site settings from data/sites.json
|
# Load site settings from data/sites.json
|
||||||
def loadSettings(self, settings=None):
|
def loadSettings(self, settings=None):
|
||||||
if not settings:
|
if not settings:
|
||||||
settings = json.load(open("%s/sites.json" % config.data_dir)).get(self.address)
|
try:
|
||||||
|
settings = json.load(open(f'{config.data_dir}/sites.json')).get(self.address)
|
||||||
|
except Exception as err:
|
||||||
|
logging.error(f'Error loading {config.data_dir}/sites.json: {err}')
|
||||||
|
settings = {}
|
||||||
if settings:
|
if settings:
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
if "cache" not in settings:
|
if "cache" not in settings:
|
||||||
|
|
|
@ -31,17 +31,18 @@ class SiteManager(object):
|
||||||
@util.Noparallel()
|
@util.Noparallel()
|
||||||
def load(self, cleanup=True, startup=False):
|
def load(self, cleanup=True, startup=False):
|
||||||
from .Site import Site
|
from .Site import Site
|
||||||
self.log.info("Loading sites... (cleanup: %s, startup: %s)" % (cleanup, startup))
|
self.log.info(f'Loading sites... ({cleanup=}, {startup=})')
|
||||||
self.loaded = False
|
self.loaded = False
|
||||||
address_found = []
|
address_found = []
|
||||||
added = 0
|
added = 0
|
||||||
load_s = time.time()
|
load_s = time.time()
|
||||||
# Load new adresses
|
# Load new adresses
|
||||||
try:
|
try:
|
||||||
json_path = "%s/sites.json" % config.data_dir
|
json_path = f"{config.data_dir}/sites.json"
|
||||||
data = json.load(open(json_path))
|
data = json.load(open(json_path))
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
raise Exception("Unable to load %s: %s" % (json_path, err))
|
self.log.error(f"Unable to load {json_path}: {err}")
|
||||||
|
data = {}
|
||||||
|
|
||||||
sites_need = []
|
sites_need = []
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue