Merge branch 'wip' of gitlab.psi.ch-samenv:samenv/frappy into wip

This commit is contained in:
zolliker 2023-06-06 16:46:31 +02:00
commit 9a9a22588f
3 changed files with 22 additions and 4 deletions

View File

@ -169,7 +169,7 @@ class Parameter(Accessible):
OrType(FloatRange(0), EnumType(always=0, never=999999999, default=-1)), OrType(FloatRange(0), EnumType(always=0, never=999999999, default=-1)),
export=False, default=-1) export=False, default=-1)
influences = Property( influences = Property(
'optional hint about effected parameters', ArrayOf(StringType()), 'optional hint about affected parameters', ArrayOf(StringType()),
extname='influences', export=True, mandatory=False, default=[]) extname='influences', export=True, mandatory=False, default=[])
# used on the instance copy only # used on the instance copy only
@ -367,7 +367,7 @@ class Command(Accessible):
'datatype of the result from the command, or None', NoneOr(DataTypeType()), 'datatype of the result from the command, or None', NoneOr(DataTypeType()),
export=False, mandatory=True) export=False, mandatory=True)
influences = Property( influences = Property(
'optional hint about effected parameters', ArrayOf(StringType()), 'optional hint about affected parameters', ArrayOf(StringType()),
extname='influences', export=True, mandatory=False, default=[]) extname='influences', export=True, mandatory=False, default=[])
func = None func = None

View File

@ -45,6 +45,7 @@ except ImportError:
DaemonContext = None DaemonContext = None
try: try:
# pylint: disable=unused-import
import systemd.daemon import systemd.daemon
except ImportError: except ImportError:
systemd = None systemd = None
@ -132,8 +133,12 @@ class Server:
while self._restart: while self._restart:
self._restart = False self._restart = False
try: try:
if systemd: # TODO: make systemd notifications configurable
if systemd: # pylint: disable=used-before-assignment
systemd.daemon.notify("STATUS=initializing") systemd.daemon.notify("STATUS=initializing")
except Exception:
systemd = None # pylint: disable=redefined-outer-name
try:
self._processCfg() self._processCfg()
if self._testonly: if self._testonly:
return return

View File

@ -383,6 +383,19 @@ SEA_TO_SECOPTYPE = {
} }
class SeaEnum(EnumType):
"""some sea enum nodes have text type -> accept '<integer>' 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): def get_datatype(paramdesc):
typ = paramdesc['type'] typ = paramdesc['type']
result = SEA_TO_SECOPTYPE.get(typ, False) result = SEA_TO_SECOPTYPE.get(typ, False)
@ -390,7 +403,7 @@ def get_datatype(paramdesc):
return result return result
# special cases # special cases
if typ == 'enum': if typ == 'enum':
return EnumType(paramdesc['enum']) return SeaEnum(paramdesc['enum'])
raise ValueError('unknown SEA type %r' % typ) raise ValueError('unknown SEA type %r' % typ)