From f6868da3b901f08316d7a770a74b28fb09b9c4e3 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Mon, 5 Jun 2023 13:55:17 +0200 Subject: [PATCH 1/2] fix systemd bug Change-Id: I8a3f1eddba9525589757d4612a5060267ea0c5db --- frappy/params.py | 4 ++-- frappy/server.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/frappy/params.py b/frappy/params.py index 428ed78..8d33871 100644 --- a/frappy/params.py +++ b/frappy/params.py @@ -169,7 +169,7 @@ class Parameter(Accessible): OrType(FloatRange(0), EnumType(always=0, never=999999999, default=-1)), export=False, default=-1) influences = Property( - 'optional hint about effected parameters', ArrayOf(StringType()), + 'optional hint about affected parameters', ArrayOf(StringType()), extname='influences', export=True, mandatory=False, default=[]) # used on the instance copy only @@ -367,7 +367,7 @@ class Command(Accessible): 'datatype of the result from the command, or None', NoneOr(DataTypeType()), export=False, mandatory=True) influences = Property( - 'optional hint about effected parameters', ArrayOf(StringType()), + 'optional hint about affected parameters', ArrayOf(StringType()), extname='influences', export=True, mandatory=False, default=[]) func = None diff --git a/frappy/server.py b/frappy/server.py index f0cfb80..e846da0 100644 --- a/frappy/server.py +++ b/frappy/server.py @@ -45,6 +45,7 @@ except ImportError: DaemonContext = None try: + # pylint: disable=unused-import import systemd.daemon except ImportError: systemd = None @@ -132,8 +133,12 @@ class Server: while self._restart: self._restart = False try: - if systemd: + # TODO: make systemd notifications configurable + if systemd: # pylint: disable=used-before-assignment systemd.daemon.notify("STATUS=initializing") + except Exception: + systemd = None # pylint: disable=redefined-outer-name + try: self._processCfg() if self._testonly: return From 5a456a82b086f6162eca782ff5df2435b6dd495a Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Mon, 5 Jun 2023 13:55:34 +0200 Subject: [PATCH 2/2] fix enum when SEA type is text Change-Id: I873045a2dac8771b844431ccda70ce1b8ff1aee5 --- frappy_psi/sea.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frappy_psi/sea.py b/frappy_psi/sea.py index 2d98f92..0fc78e0 100644 --- a/frappy_psi/sea.py +++ b/frappy_psi/sea.py @@ -383,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) @@ -390,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)