frappy.has_changed() should not be triggered repeatedly

fix bug
This commit is contained in:
2023-12-15 15:57:15 +01:00
parent 5678530e6e
commit 09237e4118

View File

@ -139,6 +139,7 @@ class FrappyConfig(Device):
meanings.remove('nodes') meanings.remove('nodes')
_trigger_change = None _trigger_change = None
_previous_shown = None _previous_shown = None
_previous_state = None
_initial_config = None _initial_config = None
_servers_loaded = False _servers_loaded = False
@ -163,7 +164,8 @@ class FrappyConfig(Device):
try: try:
cfgs = self.check_services() cfgs = self.check_services()
changes, state, remarks = self.to_consider(cfgs) changes, state, remarks = self.to_consider(cfgs)
if state != self._previous_shown and changes: if state != self._previous_state and changes:
self._previous_state = state
cmd = 'frappy.has_changed() # inserted automatically when frappy or sea servers changed' cmd = 'frappy.has_changed() # inserted automatically when frappy or sea servers changed'
controller.new_request(ScriptRequest(cmd, None, User('guest', USER))) controller.new_request(ScriptRequest(cmd, None, User('guest', USER)))
except RequestError as e: except RequestError as e:
@ -338,7 +340,7 @@ class FrappyConfig(Device):
controller = session.daemon_device._controller controller = session.daemon_device._controller
controller.block_requests(r['reqid'] for r in controller.get_queue() controller.block_requests(r['reqid'] for r in controller.get_queue()
if r['script'].startswith('frappy.has_changed()')) if r['script'].startswith('frappy.has_changed()'))
self._previous_shown = state self._previous_state = self._previous_shown = state
session.log.info(all_info(allcfg)) session.log.info(all_info(allcfg))
if changes: if changes:
@ -385,7 +387,8 @@ class FrappyConfig(Device):
error, proposed, state, remarks = fm.get_server_state(config.instrument, cfgs) error, proposed, state, remarks = fm.get_server_state(config.instrument, cfgs)
self._initial_config = proposed self._initial_config = proposed
if not error: if not error:
self._previous_shown = state # otherwise the server state will be shown on startup # do not show server state on startup
self._previous_state = self._previous_shown = state
return self._initial_config.get(service) return self._initial_config.get(service)
def has_changed(self, show_server_state='auto'): def has_changed(self, show_server_state='auto'):
@ -664,3 +667,6 @@ class FrappyNode(SecNodeDevice, Moveable):
if (code, text) == (status.ERROR, 'reconnecting'): if (code, text) == (status.ERROR, 'reconnecting'):
return '%s (frappy not running)' % result return '%s (frappy not running)' % result
return '%s (%s)' % (result, text) return '%s (%s)' % (result, text)
def doFinish(self):
return False # avoid warning in finish() when target does not match