Change leftover %-logging calls to lazy
Change-Id: I0bee8d02ac364ab93f77919cae78afa386b85c85 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30899 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
parent
9329d2b0f4
commit
a9d479ba0a
@ -318,8 +318,8 @@ class SecopClient(ProxyClient):
|
|||||||
# inform that the other party still uses a legacy identifier
|
# inform that the other party still uses a legacy identifier
|
||||||
# see e.g. Frappy Bug #4659 (https://forge.frm2.tum.de/redmine/issues/4659)
|
# see e.g. Frappy Bug #4659 (https://forge.frm2.tum.de/redmine/issues/4659)
|
||||||
if not self.secop_version.startswith(IDENTPREFIX):
|
if not self.secop_version.startswith(IDENTPREFIX):
|
||||||
self.log.warning('SEC-Node replied with legacy identify reply: %s'
|
self.log.warning('SEC-Node replied with legacy identify reply: %s',
|
||||||
% self.secop_version)
|
self.secop_version)
|
||||||
|
|
||||||
# now its safe to do secop stuff
|
# now its safe to do secop stuff
|
||||||
self._running = True
|
self._running = True
|
||||||
|
@ -186,7 +186,7 @@ class Module:
|
|||||||
elif item in LOG_LEVELS:
|
elif item in LOG_LEVELS:
|
||||||
self._log_level = item
|
self._log_level = item
|
||||||
else:
|
else:
|
||||||
self._secnode.log.error('can not set %r on module %s' % (item, self._name))
|
self._secnode.log.error('can not set %r on module %s', item, self._name)
|
||||||
self._watched_params = params
|
self._watched_params = params
|
||||||
print('--- %s:\nlog: %s, watch: %s' % (self._name, self._log_level, ' '.join(self._watched_params)))
|
print('--- %s:\nlog: %s, watch: %s' % (self._name, self._log_level, ' '.join(self._watched_params)))
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ class MainWindow(QMainWindow):
|
|||||||
# disconnect node from all events
|
# disconnect node from all events
|
||||||
node.terminate_connection()
|
node.terminate_connection()
|
||||||
self._nodeWidgets.pop(node.contactPoint)
|
self._nodeWidgets.pop(node.contactPoint)
|
||||||
self.log.debug("Closing tab with node %s" % node.nodename)
|
self.log.debug("Closing tab with node %s", node.nodename)
|
||||||
self.tab.removeTab(index)
|
self.tab.removeTab(index)
|
||||||
|
|
||||||
def _rebuildAdvanced(self, advanced):
|
def _rebuildAdvanced(self, advanced):
|
||||||
|
@ -196,7 +196,7 @@ class IOBase(Communicator):
|
|||||||
try:
|
try:
|
||||||
removeme = not cb()
|
removeme = not cb()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.error('callback: %s' % e)
|
self.log.error('callback: %s', e)
|
||||||
removeme = True
|
removeme = True
|
||||||
if removeme:
|
if removeme:
|
||||||
self._reconnectCallbacks.pop(key)
|
self._reconnectCallbacks.pop(key)
|
||||||
|
@ -108,7 +108,7 @@ class PersistentMixin(Module):
|
|||||||
result[pname] = self.parameters[pname].datatype.import_value(value)
|
result[pname] = self.parameters[pname].datatype.import_value(value)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# ignore invalid persistent data (in case parameters have changed)
|
# ignore invalid persistent data (in case parameters have changed)
|
||||||
self.log.warning('can not restore %r to %r (%r)' % (pname, value, e))
|
self.log.warning('can not restore %r to %r (%r)', pname, value, e)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def loadParameters(self):
|
def loadParameters(self):
|
||||||
|
@ -140,8 +140,8 @@ class Dispatcher:
|
|||||||
self.reset_connection(conn)
|
self.reset_connection(conn)
|
||||||
|
|
||||||
def register_module(self, moduleobj, modulename, export=True):
|
def register_module(self, moduleobj, modulename, export=True):
|
||||||
self.log.debug('registering module %r as %s (export=%r)' %
|
self.log.debug('registering module %r as %s (export=%r)',
|
||||||
(moduleobj, modulename, export))
|
moduleobj, modulename, export)
|
||||||
self._modules[modulename] = moduleobj
|
self._modules[modulename] = moduleobj
|
||||||
if export:
|
if export:
|
||||||
self._export.append(modulename)
|
self._export.append(modulename)
|
||||||
@ -168,15 +168,15 @@ class Dispatcher:
|
|||||||
return self._export[:]
|
return self._export[:]
|
||||||
|
|
||||||
def export_accessibles(self, modulename):
|
def export_accessibles(self, modulename):
|
||||||
self.log.debug('export_accessibles(%r)' % modulename)
|
self.log.debug('export_accessibles(%r)', modulename)
|
||||||
if modulename in self._export:
|
if modulename in self._export:
|
||||||
# omit export=False params!
|
# omit export=False params!
|
||||||
res = OrderedDict()
|
res = OrderedDict()
|
||||||
for aobj in self.get_module(modulename).accessibles.values():
|
for aobj in self.get_module(modulename).accessibles.values():
|
||||||
if aobj.export:
|
if aobj.export:
|
||||||
res[aobj.export] = aobj.for_export()
|
res[aobj.export] = aobj.for_export()
|
||||||
self.log.debug('list accessibles for module %s -> %r' %
|
self.log.debug('list accessibles for module %s -> %r',
|
||||||
(modulename, res))
|
modulename, res)
|
||||||
return res
|
return res
|
||||||
self.log.debug('-> module is not to be exported!')
|
self.log.debug('-> module is not to be exported!')
|
||||||
return OrderedDict()
|
return OrderedDict()
|
||||||
@ -282,7 +282,7 @@ class Dispatcher:
|
|||||||
will return return reply, may send replies to conn or
|
will return return reply, may send replies to conn or
|
||||||
activated connections in addition
|
activated connections in addition
|
||||||
"""
|
"""
|
||||||
self.log.debug('Dispatcher: handling msg: %s' % repr(msg))
|
self.log.debug('Dispatcher: handling msg: %s', repr(msg))
|
||||||
|
|
||||||
# play thread safe !
|
# play thread safe !
|
||||||
# XXX: ONLY ONE REQUEST (per dispatcher) AT A TIME
|
# XXX: ONLY ONE REQUEST (per dispatcher) AT A TIME
|
||||||
@ -292,7 +292,7 @@ class Dispatcher:
|
|||||||
if action == IDENTREQUEST:
|
if action == IDENTREQUEST:
|
||||||
action, specifier, data = '_ident', None, None
|
action, specifier, data = '_ident', None, None
|
||||||
|
|
||||||
self.log.debug('Looking for handle_%s' % action)
|
self.log.debug('Looking for handle_%s', action)
|
||||||
handler = getattr(self, 'handle_%s' % action, None)
|
handler = getattr(self, 'handle_%s' % action, None)
|
||||||
|
|
||||||
if handler:
|
if handler:
|
||||||
|
@ -131,7 +131,7 @@ class TCPRequestHandler(socketserver.BaseRequestHandler):
|
|||||||
print('====================')
|
print('====================')
|
||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
self.log.error('empty result upon msg %s' % repr(msg))
|
self.log.error('empty result upon msg %s', repr(msg))
|
||||||
if result[0].startswith(ERRORPREFIX) and not detailed_errors:
|
if result[0].startswith(ERRORPREFIX) and not detailed_errors:
|
||||||
# strip extra information
|
# strip extra information
|
||||||
result[2][2].clear()
|
result[2][2].clear()
|
||||||
@ -193,7 +193,7 @@ class TCPServer(socketserver.ThreadingTCPServer):
|
|||||||
port = int(options.pop('uri').split('://', 1)[-1])
|
port = int(options.pop('uri').split('://', 1)[-1])
|
||||||
self.detailed_errors = options.pop('detailed_errors', False)
|
self.detailed_errors = options.pop('detailed_errors', False)
|
||||||
|
|
||||||
self.log.info("TCPServer %s binding to port %d" % (name, port))
|
self.log.info("TCPServer %s binding to port %d", name, port)
|
||||||
for ntry in range(5):
|
for ntry in range(5):
|
||||||
try:
|
try:
|
||||||
socketserver.ThreadingTCPServer.__init__(
|
socketserver.ThreadingTCPServer.__init__(
|
||||||
@ -204,10 +204,10 @@ class TCPServer(socketserver.ThreadingTCPServer):
|
|||||||
# this may happen despite of allow_reuse_address
|
# this may happen despite of allow_reuse_address
|
||||||
time.sleep(0.3 * (1 << ntry)) # max accumulated sleep time: 0.3 * 31 = 9.3 sec
|
time.sleep(0.3 * (1 << ntry)) # max accumulated sleep time: 0.3 * 31 = 9.3 sec
|
||||||
else:
|
else:
|
||||||
self.log.error('could not initialize TCP Server: %r' % e)
|
self.log.error('could not initialize TCP Server: %r', e)
|
||||||
raise
|
raise
|
||||||
if ntry:
|
if ntry:
|
||||||
self.log.warning('tried again %d times after "Address already in use"' % ntry)
|
self.log.warning('tried again %d times after "Address already in use"', ntry)
|
||||||
self.log.info("TCPServer initiated")
|
self.log.info("TCPServer initiated")
|
||||||
|
|
||||||
# py35 compatibility
|
# py35 compatibility
|
||||||
|
@ -73,7 +73,7 @@ class ProxyModule(HasIO, Module):
|
|||||||
props = remoteparams.get(pname, None)
|
props = remoteparams.get(pname, None)
|
||||||
if props is None:
|
if props is None:
|
||||||
if pobj.export:
|
if pobj.export:
|
||||||
self.log.warning('remote parameter %s:%s does not exist' % (self.module, pname))
|
self.log.warning('remote parameter %s:%s does not exist', self.module, pname)
|
||||||
continue
|
continue
|
||||||
dt = props['datatype']
|
dt = props['datatype']
|
||||||
try:
|
try:
|
||||||
@ -81,28 +81,28 @@ class ProxyModule(HasIO, Module):
|
|||||||
dt.compatible(pobj.datatype)
|
dt.compatible(pobj.datatype)
|
||||||
else:
|
else:
|
||||||
if props['readonly']:
|
if props['readonly']:
|
||||||
self.log.warning('remote parameter %s:%s is read only' % (self.module, pname))
|
self.log.warning('remote parameter %s:%s is read only', self.module, pname)
|
||||||
pobj.datatype.compatible(dt)
|
pobj.datatype.compatible(dt)
|
||||||
try:
|
try:
|
||||||
dt.compatible(pobj.datatype)
|
dt.compatible(pobj.datatype)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.log.warning('remote parameter %s:%s is not fully compatible: %r != %r'
|
self.log.warning('remote parameter %s:%s is not fully compatible: %r != %r',
|
||||||
% (self.module, pname, pobj.datatype, dt))
|
self.module, pname, pobj.datatype, dt)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.log.warning('remote parameter %s:%s has an incompatible datatype: %r != %r'
|
self.log.warning('remote parameter %s:%s has an incompatible datatype: %r != %r',
|
||||||
% (self.module, pname, pobj.datatype, dt))
|
self.module, pname, pobj.datatype, dt)
|
||||||
while cmds:
|
while cmds:
|
||||||
cname, cobj = cmds.popitem()
|
cname, cobj = cmds.popitem()
|
||||||
props = remotecmds.get(cname)
|
props = remotecmds.get(cname)
|
||||||
if props is None:
|
if props is None:
|
||||||
self.log.warning('remote command %s:%s does not exist' % (self.module, cname))
|
self.log.warning('remote command %s:%s does not exist', self.module, cname)
|
||||||
continue
|
continue
|
||||||
dt = props['datatype']
|
dt = props['datatype']
|
||||||
try:
|
try:
|
||||||
cobj.datatype.compatible(dt)
|
cobj.datatype.compatible(dt)
|
||||||
except BadValueError:
|
except BadValueError:
|
||||||
self.log.warning('remote command %s:%s is not compatible: %r != %r'
|
self.log.warning('remote command %s:%s is not compatible: %r != %r',
|
||||||
% (self.module, cname, cobj.datatype, dt))
|
self.module, cname, cobj.datatype, dt)
|
||||||
# what to do if descriptive data does not match?
|
# what to do if descriptive data does not match?
|
||||||
# we might raise an exception, but this would lead to a reconnection,
|
# we might raise an exception, but this would lead to a reconnection,
|
||||||
# which might not help.
|
# which might not help.
|
||||||
|
@ -211,7 +211,7 @@ class Server:
|
|||||||
missing_super = set()
|
missing_super = set()
|
||||||
# all objs created, now start them up and interconnect
|
# all objs created, now start them up and interconnect
|
||||||
for modname, modobj in self.modules.items():
|
for modname, modobj in self.modules.items():
|
||||||
self.log.info('registering module %r' % modname)
|
self.log.info('registering module %r', modname)
|
||||||
self.dispatcher.register_module(modobj, modname, modobj.export)
|
self.dispatcher.register_module(modobj, modname, modobj.export)
|
||||||
# also call earlyInit on the modules
|
# also call earlyInit on the modules
|
||||||
modobj.earlyInit()
|
modobj.earlyInit()
|
||||||
@ -278,7 +278,7 @@ class Server:
|
|||||||
if not start_events.wait():
|
if not start_events.wait():
|
||||||
# some timeout happened
|
# some timeout happened
|
||||||
for name in start_events.waiting_for():
|
for name in start_events.waiting_for():
|
||||||
self.log.warning('timeout when starting %s' % name)
|
self.log.warning('timeout when starting %s', name)
|
||||||
self.log.info('all modules started')
|
self.log.info('all modules started')
|
||||||
history_path = os.environ.get('FRAPPY_HISTORY')
|
history_path = os.environ.get('FRAPPY_HISTORY')
|
||||||
if history_path:
|
if history_path:
|
||||||
|
@ -42,13 +42,13 @@ class SimBase:
|
|||||||
default=0.0)
|
default=0.0)
|
||||||
|
|
||||||
def reader(self, pname=k):
|
def reader(self, pname=k):
|
||||||
self.log.debug('simulated reading %s' % pname)
|
self.log.debug('simulated reading %s', pname)
|
||||||
return self.parameters[pname].value
|
return self.parameters[pname].value
|
||||||
|
|
||||||
attrs['read_' + k] = reader
|
attrs['read_' + k] = reader
|
||||||
|
|
||||||
def writer(self, newval, pname=k):
|
def writer(self, newval, pname=k):
|
||||||
self.log.debug('simulated writing %r to %s' % (newval, pname))
|
self.log.debug('simulated writing %r to %s', newval, pname)
|
||||||
self.parameters[pname].value = newval
|
self.parameters[pname].value = newval
|
||||||
return newval
|
return newval
|
||||||
|
|
||||||
|
@ -237,8 +237,8 @@ class Cryostat(CryoBase):
|
|||||||
heater = self.heater
|
heater = self.heater
|
||||||
|
|
||||||
heatflow = self.__heatLink(regulation, sample)
|
heatflow = self.__heatLink(regulation, sample)
|
||||||
self.log.debug('sample = %.5f, regulation = %.5f, heatflow = %.5g'
|
self.log.debug('sample = %.5f, regulation = %.5f, heatflow = %.5g',
|
||||||
% (sample, regulation, heatflow))
|
sample, regulation, heatflow)
|
||||||
newsample = max(0, sample + (self.__sampleLeak(sample) - heatflow)
|
newsample = max(0, sample + (self.__sampleLeak(sample) - heatflow)
|
||||||
/ self.__sampleCP(sample) * h)
|
/ self.__sampleCP(sample) * h)
|
||||||
# avoid instabilities due to too small CP
|
# avoid instabilities due to too small CP
|
||||||
@ -293,7 +293,7 @@ class Cryostat(CryoBase):
|
|||||||
lastD = _D
|
lastD = _D
|
||||||
|
|
||||||
self.log.debug('PID: P = %.2f, I = %.2f, D = %.2f, '
|
self.log.debug('PID: P = %.2f, I = %.2f, D = %.2f, '
|
||||||
'heater = %.2f' % (_P, _I, _D, heater))
|
'heater = %.2f', _P, _I, _D, heater)
|
||||||
|
|
||||||
# check for turn-around points to detect oscillations ->
|
# check for turn-around points to detect oscillations ->
|
||||||
# increase damper
|
# increase damper
|
||||||
@ -321,8 +321,8 @@ class Cryostat(CryoBase):
|
|||||||
try:
|
try:
|
||||||
self.setpoint = round(self.setpoint + clamp(
|
self.setpoint = round(self.setpoint + clamp(
|
||||||
self.target - self.setpoint, -maxdelta, maxdelta), 3)
|
self.target - self.setpoint, -maxdelta, maxdelta), 3)
|
||||||
self.log.debug('setpoint changes to %r (target %r)' %
|
self.log.debug('setpoint changes to %r (target %r)',
|
||||||
(self.setpoint, self.target))
|
self.setpoint, self.target)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
# self.target might be None
|
# self.target might be None
|
||||||
pass
|
pass
|
||||||
|
@ -169,12 +169,12 @@ class MagneticField(Drivable):
|
|||||||
if self._state == self._state.enum.switch_on:
|
if self._state == self._state.enum.switch_on:
|
||||||
# wait until switch is on
|
# wait until switch is on
|
||||||
if self._heatswitch.read_value() == 'on':
|
if self._heatswitch.read_value() == 'on':
|
||||||
self.log.debug('heatswitch is on -> ramp to %.3f' %
|
self.log.debug('heatswitch is on -> ramp to %.3f',
|
||||||
self.target)
|
self.target)
|
||||||
self._state = self._state.enum.ramp
|
self._state = self._state.enum.ramp
|
||||||
if self._state == self._state.enum.ramp:
|
if self._state == self._state.enum.ramp:
|
||||||
if self.target == self.value:
|
if self.target == self.value:
|
||||||
self.log.debug('at field! mode is %r' % self.mode)
|
self.log.debug('at field! mode is %r', self.mode)
|
||||||
if self.mode:
|
if self.mode:
|
||||||
self.log.debug('at field -> switching heater off')
|
self.log.debug('at field -> switching heater off')
|
||||||
self._state = self._state.enum.switch_off
|
self._state = self._state.enum.switch_off
|
||||||
@ -190,7 +190,7 @@ class MagneticField(Drivable):
|
|||||||
if self._state == self._state.enum.switch_off:
|
if self._state == self._state.enum.switch_off:
|
||||||
# wait until switch is off
|
# wait until switch is off
|
||||||
if self._heatswitch.read_value() == 'off':
|
if self._heatswitch.read_value() == 'off':
|
||||||
self.log.debug('heatswitch is off at %.3f' % self.value)
|
self.log.debug('heatswitch is off at %.3f', self.value)
|
||||||
self._state = self._state.enum.idle
|
self._state = self._state.enum.idle
|
||||||
self.read_status() # update async
|
self.read_status() # update async
|
||||||
time.sleep(max(0.01, ts + loopdelay - time.time()))
|
time.sleep(max(0.01, ts + loopdelay - time.time()))
|
||||||
|
@ -162,7 +162,7 @@ class GarfieldMagnet(SequencerMixin, Drivable):
|
|||||||
minslope = min(entry[0]
|
minslope = min(entry[0]
|
||||||
for entry in self.calibrationtable.values())
|
for entry in self.calibrationtable.values())
|
||||||
self.log.error(
|
self.log.error(
|
||||||
'unconfigured calibration for symmetry %r' %
|
'unconfigured calibration for symmetry %r',
|
||||||
self._symmetry.value)
|
self._symmetry.value)
|
||||||
return [minslope, 0, 0, 0, 0]
|
return [minslope, 0, 0, 0, 0]
|
||||||
|
|
||||||
|
@ -386,10 +386,10 @@ class Temp(PpmsDrivable):
|
|||||||
return
|
return
|
||||||
self.setpoint, self.workingramp, self.approachmode = self._last_settings = settings
|
self.setpoint, self.workingramp, self.approachmode = self._last_settings = settings
|
||||||
if self.setpoint != 10 or not self._wait_at10:
|
if self.setpoint != 10 or not self._wait_at10:
|
||||||
self.log.debug('read back target %g %r' % (self.setpoint, self._wait_at10))
|
self.log.debug('read back target %g %r', self.setpoint, self._wait_at10)
|
||||||
self.target = self.setpoint
|
self.target = self.setpoint
|
||||||
if self.workingramp != 2 or not self._ramp_at_limit:
|
if self.workingramp != 2 or not self._ramp_at_limit:
|
||||||
self.log.debug('read back ramp %g %r' % (self.workingramp, self._ramp_at_limit))
|
self.log.debug('read back ramp %g %r', self.workingramp, self._ramp_at_limit)
|
||||||
self.ramp = self.workingramp
|
self.ramp = self.workingramp
|
||||||
|
|
||||||
def _write_params(self, setpoint, ramp, approachmode):
|
def _write_params(self, setpoint, ramp, approachmode):
|
||||||
@ -407,7 +407,7 @@ class Temp(PpmsDrivable):
|
|||||||
self._ramp_at_limit = ramp_at_limit
|
self._ramp_at_limit = ramp_at_limit
|
||||||
self.calc_expected(setpoint, ramp)
|
self.calc_expected(setpoint, ramp)
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
'change_temp v %r s %r r %r w %r l %r' % (self.value, setpoint, ramp, wait_at10, ramp_at_limit))
|
'change_temp v %r s %r r %r w %r l %r', self.value, setpoint, ramp, wait_at10, ramp_at_limit)
|
||||||
self.comm_write('TEMP %g,%g,%d' % (setpoint, ramp, approachmode))
|
self.comm_write('TEMP %g,%g,%d' % (setpoint, ramp, approachmode))
|
||||||
self.read_params()
|
self.read_params()
|
||||||
|
|
||||||
@ -465,7 +465,7 @@ class Temp(PpmsDrivable):
|
|||||||
self.status = (StatusType.BUSY, 'changed target')
|
self.status = (StatusType.BUSY, 'changed target')
|
||||||
self._last_change = time.time()
|
self._last_change = time.time()
|
||||||
self._write_params(target, self.ramp, self.approachmode)
|
self._write_params(target, self.ramp, self.approachmode)
|
||||||
self.log.debug('write_target %s' % repr((self.setpoint, target, self._wait_at10)))
|
self.log.debug('write_target %s', repr((self.setpoint, target, self._wait_at10)))
|
||||||
return target
|
return target
|
||||||
|
|
||||||
def write_approachmode(self, value):
|
def write_approachmode(self, value):
|
||||||
|
@ -213,7 +213,7 @@ class Motor(PersistentMixin, HasIO, Drivable):
|
|||||||
self.log.error('saved encoder value (%.2f) does not match reading (%.2f %.2f)',
|
self.log.error('saved encoder value (%.2f) does not match reading (%.2f %.2f)',
|
||||||
self.encoder, encoder_from_hw, adjusted_encoder)
|
self.encoder, encoder_from_hw, adjusted_encoder)
|
||||||
if adjusted_encoder != encoder_from_hw:
|
if adjusted_encoder != encoder_from_hw:
|
||||||
self.log.info('take next closest encoder value (%.2f)' % adjusted_encoder)
|
self.log.info('take next closest encoder value (%.2f)', adjusted_encoder)
|
||||||
self._need_reset = True
|
self._need_reset = True
|
||||||
self.status = ERROR, 'saved encoder value does not match reading'
|
self.status = ERROR, 'saved encoder value does not match reading'
|
||||||
self._write_axispar(adjusted_encoder - self.zero, ENCODER_ADR, ANGLE_SCALE, readback=False)
|
self._write_axispar(adjusted_encoder - self.zero, ENCODER_ADR, ANGLE_SCALE, readback=False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user