From 34351079485fac422ea30dfa19fe300ec9f43b64 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Thu, 11 Mar 2021 15:53:57 +0100 Subject: [PATCH] fix access to sea config dir - removed unused property json_path - do not take the first directory in config path, but the first directory with a sea subdirectory Change-Id: I4f0d72936ca616134c38568d88c57a33a3397ec6 --- secop_psi/sea.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/secop_psi/sea.py b/secop_psi/sea.py index a92f837..8cad399 100644 --- a/secop_psi/sea.py +++ b/secop_psi/sea.py @@ -35,6 +35,7 @@ rx:bla rx bla /some/rx_a/bla rx bla /some/rx_a import json import threading import time +import os from os.path import expanduser, join from secop.client import ProxyClient @@ -66,7 +67,12 @@ remote_paths = . SEA_DIR = expanduser('~/sea') -confdir = getGeneralConfig()['confdir'].split(':', 1)[0] +for confdir in getGeneralConfig()['confdir'].split(os.pathsep): + seaconfdir = join(confdir, 'sea') + if os.exists(seaconfdir): + break +else: + seaconfdir = None def get_sea_port(instance): @@ -87,8 +93,6 @@ def get_sea_port(instance): class SeaClient(ProxyClient, Module): """connection to SEA""" - json_path = Property('path to SEA json descriptors', StringType()) - uri = Parameter('hostname:portnumber', datatype=StringType(), default='localhost:5000') timeout = Parameter('timeout', datatype=FloatRange(0), default=10) @@ -242,11 +246,11 @@ class SeaClient(ProxyClient, Module): samenv, reply = json.loads(reply) samenv = samenv.replace('/', '_') result = [] - with open(join(confdir, 'sea', samenv + '.cfg'), 'w') as cfp: + with open(join(seaconfdir, samenv + '.cfg'), 'w') as cfp: cfp.write(CFG_HEADER % dict(samenv=samenv)) for filename, obj, descr in reply: content = json.dumps([obj, descr]).replace('}, {', '},\n{') - with open(join(confdir, 'sea', filename + '.json'), 'w') as fp: + with open(join(seaconfdir, filename + '.json'), 'w') as fp: fp.write(content + '\n') if descr[0].get('cmd', '').startswith('run '): modcls = 'SeaDrivable' @@ -291,7 +295,7 @@ class SeaModule(Module): remote_paths = cfgdict.pop('remote_paths', '') if 'description' not in cfgdict: cfgdict['description'] = '%s (remote_paths=%s)' % (json_descr, remote_paths) - with open(join(confdir, 'sea', json_descr + '.json')) as fp: + with open(join(seaconfdir, json_descr + '.json')) as fp: sea_object, descr = json.load(fp) remote_paths = remote_paths.split() if remote_paths: