From a3453e6b0eeb4a275acfa3be184a5bd6a0772bcc Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Mon, 20 Jun 2022 15:03:39 +0200 Subject: [PATCH] frappyman: inherit PYTHONPATH from starting process on SINQ instruments, when frappy is started from nicos, nicos.conf contains PYTHONPATH = /home/:/home//.local... this should be applied to the frappy process too --- frappyman.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frappyman.py b/frappyman.py index 75e0e9c..4b058be 100644 --- a/frappyman.py +++ b/frappyman.py @@ -76,6 +76,13 @@ class FrappyManager(ServiceManager): cfgpaths = self.config_dirs(ins, service) if cfgpaths: env['FRAPPY_CONFDIR'] = os.pathsep.join(cfgpaths) + # merge PYTHONPATH from servicemanager.cfg with the one from environment + pypathlist = [] + for pypath in env.get('PYTHONPATH'), os.environ.get('PYTHONPATH'): + if pypath is not None: + pypathlist.extend(p for p in pypath.split(':') if p not in pypathlist) + if pypathlist: + env['PYTHONPATH'] = os.environ['PYTHONPATH'] = ':'.join(pypathlist) return start_dir, env def do_start(self, ins, service=None, cfg='', restart=False, wait=False, logger=None):