diff --git a/src/calng/CalibrationManager.py b/src/calng/CalibrationManager.py index fe2442c76821c77b9bf18938277031597d0ab42a..ceba1f2415119d516ff04a0499ee3e6b497cb456 100644 --- a/src/calng/CalibrationManager.py +++ b/src/calng/CalibrationManager.py @@ -26,12 +26,14 @@ from karabo.middlelayer import ( from karabo import version as karaboVersion from ._version import version as deviceVersion + ''' Device states: - INIT: When the device is starting up - ACTIVE: When the device is ready to manage a calibration pipeline - CHANGING: When the device is actively changing the pipeline configuration - ERROR: Recoverable error, only allows server restart + - UNKNOWN: Unrecoverable error ''' @@ -335,6 +337,7 @@ class CalibrationManager(DeviceClientBase, Device): detectorType = String( displayedName='Detector type', + description='Type of the detector to manage.', options=['AGIPD', 'LPD', 'DSSC', 'Jungfrau', 'ePix100', 'pnCCD', 'FastCCD'], accessMode=AccessMode.INITONLY, @@ -561,8 +564,7 @@ class CalibrationManager(DeviceClientBase, Device): else: break else: - self.state = State.UNKNOWN - self._set_status(f'Topology not available after {i+1} tries') + self._set_fatal(f'Topology not available after {i+1} tries') return self.logger.debug(f'Topology arrived after {i+1} tries') @@ -586,6 +588,12 @@ class CalibrationManager(DeviceClientBase, Device): self.state = State.ERROR self._set_status(text, level=logging.ERROR) + def _set_fatal(self, text): + """Set the device into unknown state and log an error message.""" + + self.state = State.UNKNOWN + self._set_status(text, level=logging.CRITICAL) + def _set_exception(self, text, e): """Set the device into error upon an exception.""" @@ -662,11 +670,11 @@ class CalibrationManager(DeviceClientBase, Device): body=json.dumps({'server': {'command': command}}))) except (ConnectionError, HTTPError) as e: raise RuntimeError( - f'Failed sending \'{command}\' to {name} on ' + f'Failed sending `{command}` to {name} on ' f'{urlparse(self._server_hosts[name]).hostname}: {e}') if not json.loads(reply.body)['success']: - raise RuntimeError('Command \'{command}\' for {name} failed') + raise RuntimeError('Command `{command}` for {name} failed') while True: await sleep(self.webserverApi.statePollInterval.value) @@ -729,7 +737,7 @@ class CalibrationManager(DeviceClientBase, Device): if 'error' in s['status']} if servers_in_error: - err.append(f'- Device server on {hostname} are in error state' + err.append(f'- Device servers on {hostname} are in error state' + ', '.join(servers_in_error)) continue @@ -737,7 +745,7 @@ class CalibrationManager(DeviceClientBase, Device): if not s['control_allowed']} if servers_disabled: - err.append(f'- Device servers on {hostname} not controllable ' + err.append(f'- Device servers on {hostname} not controllable ' f'via webserver: ' + ', '.join(servers_disabled)) continue @@ -1097,14 +1105,14 @@ class CalibrationManager(DeviceClientBase, Device): for device_id in device_ids: callNoWait(device_id, slot, *args) - self.logger.debug(f'Called {device_id}.{slot}({args})') + self.logger.debug(f'Called {device_id}.{slot}{args}') async def _call_on_corrections(self, slot, *args): """Call a slot on all correction devices.""" if self._correction_device_ids: self._call(self._correction_device_ids, slot, *args) - self.logger.info(f'Called <CORR>.{slot}({args})') + self.logger.info(f'Called <CORR>.{slot}{args}') def _set(self, device_ids, key, value): """Set the same property on a list of devices."""