check configuration
This commit is contained in:
parent
57d6039e18
commit
f8beb5f859
2 changed files with 8 additions and 3 deletions
7
run.py
7
run.py
|
@ -39,9 +39,10 @@ def stacosys_server(config_pathname):
|
|||
logger.error(f"Configuration file '{config_pathname}' not found.")
|
||||
sys.exit(1)
|
||||
|
||||
# initialize config
|
||||
# load config
|
||||
conf = Config.load(config_pathname)
|
||||
logger.info(conf.__repr__())
|
||||
conf.check()
|
||||
logger.info(conf)
|
||||
|
||||
# check database file exists (prevents from creating a fresh db)
|
||||
db_pathname = conf.get(ConfigParameter.DB_SQLITE_FILE)
|
||||
|
@ -70,7 +71,7 @@ def stacosys_server(config_pathname):
|
|||
conf.get_int(ConfigParameter.SMTP_PORT),
|
||||
conf.get(ConfigParameter.SMTP_LOGIN),
|
||||
conf.get(ConfigParameter.SMTP_PASSWORD),
|
||||
conf.get(ConfigParameter.SITE_ADMIN_EMAIL)
|
||||
conf.get(ConfigParameter.SITE_ADMIN_EMAIL),
|
||||
)
|
||||
|
||||
# inject config parameters into flask
|
||||
|
|
|
@ -74,6 +74,10 @@ class Config:
|
|||
assert value in ("yes", "true", "no", "false")
|
||||
return value in ("yes", "true")
|
||||
|
||||
def check(self):
|
||||
for key in ConfigParameter:
|
||||
assert self.get(key), f"Paramètre introuvable : {key.value}"
|
||||
|
||||
def __repr__(self):
|
||||
d = dict()
|
||||
for section in self._cfg.sections():
|
||||
|
|
Loading…
Add table
Reference in a new issue