From f9f713811ef3d46941eca2fb731addc152b3f756 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Wed, 16 Oct 2024 15:10:15 +0200 Subject: [PATCH] do not fail when generalConfig.init() is called twice Change-Id: I7132b71f906fc8a77b6fedcdcc2c7d4a3e48830a Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/34818 Reviewed-by: Markus Zolliker Tested-by: Jenkins Automated Tests Reviewed-by: Enrico Faulhaber --- frappy/lib/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frappy/lib/__init__.py b/frappy/lib/__init__.py index d93e7c9..d835c72 100644 --- a/frappy/lib/__init__.py +++ b/frappy/lib/__init__.py @@ -76,18 +76,20 @@ class GeneralConfig: if (Path(sys.executable).suffix == ".exe" and not Path(sys.executable).name.startswith('python')): # special MS windows environment - self.update_defaults(piddir=Path('./'), logdir=Path('./log'), confdir=Path('./')) + confdir = Path('./') + self.update_defaults(piddir=Path('./'), logdir=Path('./log')) elif path.exists(path.join(repodir, 'cfg')): # running from git repo - self.set_default('confdir', repodir / 'cfg') + confdir = repodir / 'cfg' # take logdir and piddir from /cfg/generalConfig.cfg else: # running on installed system (typically with systemd) self.update_defaults( piddir=Path('/var/run/frappy'), logdir=Path('/var/log'), - confdir=Path('/etc/frappy') ) + confdir = Path('/etc/frappy') + self.set_default('confdir', confdir) if configfile is None: configfile = environ.get('FRAPPY_CONFIG_FILE') if configfile: @@ -95,7 +97,7 @@ class GeneralConfig: if not configfile.exists(): raise FileNotFoundError(configfile) else: - configfile = self['confdir'] / 'generalConfig.cfg' + configfile = confdir / 'generalConfig.cfg' if not configfile.exists(): configfile = None if configfile: