From 331dc544adf24ac84d9fd4385797d3f1286b4e75 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Fri, 9 Apr 2021 11:46:24 +0200 Subject: [PATCH] use different names for seaconn in different frappy services --- secop_psi/sea.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/secop_psi/sea.py b/secop_psi/sea.py index a43a190..280f60e 100644 --- a/secop_psi/sea.py +++ b/secop_psi/sea.py @@ -48,20 +48,26 @@ from secop.modules import Attached, Command, Done, Drivable, \ Module, Parameter, Property, Readable, Writable from secop.protocol.dispatcher import make_update -CFG_HEADER = """[seaconn] + +CFG_HEADER = """[%(seaconn)s] class = secop_psi.sea.SeaClient description = SEA connection to %(samenv)s config = %(config)s -%(export)s +service = %(service)s """ CFG_MODULE = """ [%(module)s] class = secop_psi.sea.%(modcls)s -iodev = seaconn +iodev = %(seaconn)s sea_object = %(module)s """ +SERVICE_NAMES = { + 'config': 'main', + 'stick': 'stick', + 'addon': 'addons', +} SEA_DIR = expanduser('~/sea') for confdir in getGeneralConfig()['confdir'].split(os.pathsep): @@ -281,12 +287,14 @@ class SeaClient(ProxyClient, Module): result = [] for filename, descr in modules.items(): - stripped = filename.rpartition('.')[0] + stripped, _, ext = filename.rpartition('.') + service = SERVICE_NAMES[ext] + seaconn = 'sea_' + service with open(join(seaconfdir, stripped + '.cfg'), 'w') as fp: - fp.write(CFG_HEADER % dict(samenv=samenv, config=filename, - export='' if filename.endswith('.config') else 'export=False')) + fp.write(CFG_HEADER % dict( + samenv=samenv, config=filename, seaconn=seaconn, service=service)) for obj in descr: - fp.write(CFG_MODULE % dict(modcls=modcls[obj], module=obj)) + fp.write(CFG_MODULE % dict(modcls=modcls[obj], module=obj, seaconn=seaconn)) content = json.dumps(descr).replace('}, {', '},\n{') with open(join(seaconfdir, filename + '.json'), 'w') as fp: fp.write(content + '\n')