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')
_trigger_change = None
_previous_shown = None
_previous_state = None
_initial_config = None
_servers_loaded = False
@ -163,7 +164,8 @@ class FrappyConfig(Device):
try:
cfgs = self.check_services()
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'
controller.new_request(ScriptRequest(cmd, None, User('guest', USER)))
except RequestError as e:
@ -338,7 +340,7 @@ class FrappyConfig(Device):
controller = session.daemon_device._controller
controller.block_requests(r['reqid'] for r in controller.get_queue()
if r['script'].startswith('frappy.has_changed()'))
self._previous_shown = state
self._previous_state = self._previous_shown = state
session.log.info(all_info(allcfg))
if changes:
@ -385,7 +387,8 @@ class FrappyConfig(Device):
error, proposed, state, remarks = fm.get_server_state(config.instrument, cfgs)
self._initial_config = proposed
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)
def has_changed(self, show_server_state='auto'):
@ -664,3 +667,6 @@ class FrappyNode(SecNodeDevice, Moveable):
if (code, text) == (status.ERROR, 'reconnecting'):
return '%s (frappy not running)' % result
return '%s (%s)' % (result, text)
def doFinish(self):
return False # avoid warning in finish() when target does not match