forked from 0x2620/pandora
improve output if config can not be parsed
This commit is contained in:
parent
9e88f29126
commit
310343c81c
1 changed files with 16 additions and 6 deletions
|
@ -35,18 +35,28 @@ def get_version():
|
||||||
return u'%s' % rev
|
return u'%s' % rev
|
||||||
return u'unknown'
|
return u'unknown'
|
||||||
|
|
||||||
def load_config():
|
def load_config(init=False):
|
||||||
with open(settings.SITE_CONFIG) as f:
|
with open(settings.SITE_CONFIG) as f:
|
||||||
try:
|
try:
|
||||||
config = ox.jsonc.load(f)
|
config = ox.jsonc.load(f)
|
||||||
except:
|
except ValueError as e:
|
||||||
config = None
|
if init:
|
||||||
|
print("Failed to parse %s:\n" % settings.SITE_CONFIG)
|
||||||
|
print (e)
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
config = None
|
||||||
|
|
||||||
with open(settings.DEFAULT_CONFIG) as f:
|
with open(settings.DEFAULT_CONFIG) as f:
|
||||||
try:
|
try:
|
||||||
default = ox.jsonc.load(f)
|
default = ox.jsonc.load(f)
|
||||||
except:
|
except ValueError as e:
|
||||||
default = None
|
if init:
|
||||||
|
print("Failed to default config %s:\n" % settings.DEFAULT_CONFIG)
|
||||||
|
print (e)
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
default = None
|
||||||
|
|
||||||
if config:
|
if config:
|
||||||
settings.SITENAME = config['site']['name']
|
settings.SITENAME = config['site']['name']
|
||||||
|
@ -306,7 +316,7 @@ def update_geoip(force=False):
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
if not settings.RELOADER_RUNNING:
|
if not settings.RELOADER_RUNNING:
|
||||||
load_config()
|
load_config(True)
|
||||||
if settings.RELOAD_CONFIG:
|
if settings.RELOAD_CONFIG:
|
||||||
thread.start_new_thread(reloader_thread, ())
|
thread.start_new_thread(reloader_thread, ())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue