From 5727ecbc7fed8b41ac55ebf24c1f71e6fdd2a5a5 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Tue, 20 Jun 2023 09:09:51 +0200 Subject: [PATCH] frappy_psi.sea: bug fixes - left over fixes from config file format change - sea enums might be texts - create SeaEnum datatype for this Change-Id: I1f1baeeb4d6a0b13b5ec42d651bc0fc37b0fdf2c Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31380 Tested-by: Jenkins Automated Tests Reviewed-by: Markus Zolliker --- frappy_psi/sea.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/frappy_psi/sea.py b/frappy_psi/sea.py index c78b6f07..5b5f4d7a 100644 --- a/frappy_psi/sea.py +++ b/frappy_psi/sea.py @@ -48,9 +48,8 @@ from frappy.modules import Attached, Command, Done, Drivable, \ from frappy.protocol.dispatcher import make_update -CFG_HEADER = """Node( - description = '''%(nodedescr)s''', - id = %(config)s.sea.psi.ch, +CFG_HEADER = """Node('%(config)s.sea.psi.ch', + '''%(nodedescr)s''', ) Mod(%(seaconn)r, 'frappy_psi.sea.SeaClient', @@ -384,6 +383,19 @@ SEA_TO_SECOPTYPE = { } +class SeaEnum(EnumType): + """some sea enum nodes have text type -> accept '' also""" + def copy(self): + return SeaEnum(self._enum) + + def __call__(self, value): + try: + value = int(value) + except TypeError: + pass + return super().__call__(value) + + def get_datatype(paramdesc): typ = paramdesc['type'] result = SEA_TO_SECOPTYPE.get(typ, False) @@ -391,7 +403,7 @@ def get_datatype(paramdesc): return result # special cases if typ == 'enum': - return EnumType(paramdesc['enum']) + return SeaEnum(paramdesc['enum']) raise ValueError('unknown SEA type %r' % typ) @@ -451,7 +463,6 @@ class SeaModule(Module): descr['params'].pop(0) else: # filter by relative paths - rel_paths = rel_paths.split() result = [] is_running = None for rpath in rel_paths: @@ -493,9 +504,7 @@ class SeaModule(Module): raise ConfigError(f"{sea_object}/{paramdesc['path']} is not writable") paramdesc['key'] = 'target' paramdesc['readonly'] = False - extra_module_set = cfgdict.pop('extra_modules', ()) - if extra_module_set: - extra_module_set = set(extra_module_set.replace(',', ' ').split()) + extra_module_set = set(cfgdict.pop('extra_modules', ())) path2param = {} attributes = {'sea_object': sea_object, 'path2param': path2param}