generalConfig: fix the case when confdir is a list of paths
convert all env variable values containing ':' into a list of paths + fix one case where an env variable is not converted to a Path + remove unused _gcfg_help Change-Id: Ibc51ab4606ca51e0e87d0fedfac1aca4952f3270 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/34872 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
parent
eac58982d9
commit
8e05090795
@ -37,10 +37,6 @@ from pathlib import Path
|
||||
SECoP_DEFAULT_PORT = 10767
|
||||
|
||||
|
||||
_gcfg_help = """
|
||||
"""
|
||||
|
||||
|
||||
class GeneralConfig:
|
||||
"""generalConfig holds server configuration items
|
||||
|
||||
@ -94,17 +90,16 @@ class GeneralConfig:
|
||||
if cfg.get('confdir') is None:
|
||||
cfg['confdir'] = configfile.parent
|
||||
# environment variables will overwrite the config file
|
||||
missing_keys = []
|
||||
for key in mandatory:
|
||||
env = environ.get(f'FRAPPY_{key.upper()}')
|
||||
if env is not None:
|
||||
if ':' in env:
|
||||
cfg[key] = [Path(v) for v in env.split(':')]
|
||||
else:
|
||||
cfg[key] = Path(env)
|
||||
missing_keys = [
|
||||
key for key in mandatory
|
||||
if cfg.get(key) is None and self.defaults.get(key) is None
|
||||
]
|
||||
env = environ.get(f'FRAPPY_{key.upper()}') or cfg.get(key)
|
||||
if env is None:
|
||||
if self.defaults.get(key) is None:
|
||||
missing_keys.append(key)
|
||||
else:
|
||||
if not isinstance(env, Path):
|
||||
env = [Path(v) for v in env.split(':')]
|
||||
cfg[key] = env
|
||||
if missing_keys:
|
||||
if configfile:
|
||||
raise KeyError(f"missing value for {' and '.join(missing_keys)} in {configfile}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user