From 83f04cf670558272e8518d9763b845494edd3ab6 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Fri, 29 Aug 2025 11:20:35 +0200 Subject: [PATCH] try to fix the case the *_ROOT dir is not in sys.path --- base.py | 7 ++++--- frappyman.py | 11 +++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/base.py b/base.py index 5a75daf..6567634 100644 --- a/base.py +++ b/base.py @@ -302,7 +302,10 @@ class ServiceManager: if not ins: raise UsageError('need instance') env = self.env[ins] - return env.get('%s_ROOT' % gr, ''), env + startdir = env.get('%s_ROOT' % gr, '') + if startdir not in sys.path: + sys.path.insert(0, startdir) + return startdir, env def do_start(self, ins, service=None, cfg='', restart=False, wait=False, logger=None, opts=''): if not ins: @@ -367,8 +370,6 @@ class ServiceManager: start_dir, env = self.prepare_start(ins, service_i, cfg) env = dict(os.environ, **env, Instrument=ins) os.chdir(start_dir) - if start_dir not in sys.path: - sys.path.insert(0, start_dir) nicosenv = '/home/nicos/nicos/nicosenv/bin/' if exists(nicosenv): env['PATH'] = f"{nicosenv}:{env['PATH']}" diff --git a/frappyman.py b/frappyman.py index bf00622..5e1b2fd 100644 --- a/frappyman.py +++ b/frappyman.py @@ -46,7 +46,11 @@ class Config: def get(cls, cfgfile): if not cls.process_file: import logging - from frappy.config import process_file + try: + from frappy.config import process_file + except Exception as e: + print(sys.path) + raise from frappy.lib import generalConfig generalConfig.init() cls.log = logging.getLogger('frappyman') @@ -165,9 +169,7 @@ class FrappyManager(ServiceManager): return [i for i in ins_list if i in cfgs] def get_nodes(self, ins='', service=None): - start_dir = ServiceManager.prepare_start(self, ins, None)[0] - if start_dir not in sys.path: - sys.path.insert(0, start_dir) + ServiceManager.prepare_start(self, ins, None) nodes = [] services = self.services if service is None else [service] for service in services: @@ -301,6 +303,7 @@ class FrappyManager(ServiceManager): def do_listcfg(self, ins='', service='', prt=print): if not ins: raise UsageError('missing instance') + ServiceManager.prepare_start(self, ins, service) self.all_cfg(ins, service, True) seacfgpat = re.compile(r'(.*)(\.config|\.stick|\.addon)') keylen = max((max(len(k) for k in cfgs) for cfgs in self.list_info.values()), default=1)