diff --git a/frappy/client/__init__.py b/frappy/client/__init__.py index 2352bba..123817b 100644 --- a/frappy/client/__init__.py +++ b/frappy/client/__init__.py @@ -318,8 +318,8 @@ class SecopClient(ProxyClient): # inform that the other party still uses a legacy identifier # see e.g. Frappy Bug #4659 (https://forge.frm2.tum.de/redmine/issues/4659) if not self.secop_version.startswith(IDENTPREFIX): - self.log.warning('SEC-Node replied with legacy identify reply: %s' - % self.secop_version) + self.log.warning('SEC-Node replied with legacy identify reply: %s', + self.secop_version) # now its safe to do secop stuff self._running = True diff --git a/frappy/client/interactive.py b/frappy/client/interactive.py index 8cf9862..e53d4ab 100644 --- a/frappy/client/interactive.py +++ b/frappy/client/interactive.py @@ -186,7 +186,7 @@ class Module: elif item in LOG_LEVELS: self._log_level = item 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 print('--- %s:\nlog: %s, watch: %s' % (self._name, self._log_level, ' '.join(self._watched_params))) diff --git a/frappy/gui/mainwindow.py b/frappy/gui/mainwindow.py index 1fb93ea..a2830e9 100644 --- a/frappy/gui/mainwindow.py +++ b/frappy/gui/mainwindow.py @@ -272,7 +272,7 @@ class MainWindow(QMainWindow): # disconnect node from all events node.terminate_connection() 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) def _rebuildAdvanced(self, advanced): diff --git a/frappy/io.py b/frappy/io.py index f932086..9060797 100644 --- a/frappy/io.py +++ b/frappy/io.py @@ -98,11 +98,11 @@ class HasIodev(HasIO): class IOBase(Communicator): """base of StringIO and BytesIO""" uri = Property("""uri for serial connection - + one of the following: - + - ``tcp://:`` (see :class:`frappy.lib.asynconn.AsynTcp`) - + - ``serial://?baudrate=...`` (see :class:`frappy.lib.asynconn.AsynSerial`) """, datatype=StringType()) timeout = Parameter('timeout', datatype=FloatRange(0), default=2) @@ -196,7 +196,7 @@ class IOBase(Communicator): try: removeme = not cb() except Exception as e: - self.log.error('callback: %s' % e) + self.log.error('callback: %s', e) removeme = True if removeme: self._reconnectCallbacks.pop(key) diff --git a/frappy/persistent.py b/frappy/persistent.py index 2a54957..c48373a 100644 --- a/frappy/persistent.py +++ b/frappy/persistent.py @@ -108,7 +108,7 @@ class PersistentMixin(Module): result[pname] = self.parameters[pname].datatype.import_value(value) except Exception as e: # 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 def loadParameters(self): diff --git a/frappy/protocol/dispatcher.py b/frappy/protocol/dispatcher.py index 78f18a5..8efe610 100644 --- a/frappy/protocol/dispatcher.py +++ b/frappy/protocol/dispatcher.py @@ -140,8 +140,8 @@ class Dispatcher: self.reset_connection(conn) def register_module(self, moduleobj, modulename, export=True): - self.log.debug('registering module %r as %s (export=%r)' % - (moduleobj, modulename, export)) + self.log.debug('registering module %r as %s (export=%r)', + moduleobj, modulename, export) self._modules[modulename] = moduleobj if export: self._export.append(modulename) @@ -168,15 +168,15 @@ class Dispatcher: return self._export[:] def export_accessibles(self, modulename): - self.log.debug('export_accessibles(%r)' % modulename) + self.log.debug('export_accessibles(%r)', modulename) if modulename in self._export: # omit export=False params! res = OrderedDict() for aobj in self.get_module(modulename).accessibles.values(): if aobj.export: res[aobj.export] = aobj.for_export() - self.log.debug('list accessibles for module %s -> %r' % - (modulename, res)) + self.log.debug('list accessibles for module %s -> %r', + modulename, res) return res self.log.debug('-> module is not to be exported!') return OrderedDict() @@ -282,7 +282,7 @@ class Dispatcher: will return return reply, may send replies to conn or 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 ! # XXX: ONLY ONE REQUEST (per dispatcher) AT A TIME @@ -292,7 +292,7 @@ class Dispatcher: if action == IDENTREQUEST: 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) if handler: diff --git a/frappy/protocol/interface/tcp.py b/frappy/protocol/interface/tcp.py index 9a4132b..d925f27 100644 --- a/frappy/protocol/interface/tcp.py +++ b/frappy/protocol/interface/tcp.py @@ -131,7 +131,7 @@ class TCPRequestHandler(socketserver.BaseRequestHandler): print('====================') 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: # strip extra information result[2][2].clear() @@ -193,7 +193,7 @@ class TCPServer(socketserver.ThreadingTCPServer): port = int(options.pop('uri').split('://', 1)[-1]) 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): try: socketserver.ThreadingTCPServer.__init__( @@ -204,10 +204,10 @@ class TCPServer(socketserver.ThreadingTCPServer): # this may happen despite of allow_reuse_address time.sleep(0.3 * (1 << ntry)) # max accumulated sleep time: 0.3 * 31 = 9.3 sec else: - self.log.error('could not initialize TCP Server: %r' % e) + self.log.error('could not initialize TCP Server: %r', e) raise 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") # py35 compatibility diff --git a/frappy/proxy.py b/frappy/proxy.py index 72640f2..e504191 100644 --- a/frappy/proxy.py +++ b/frappy/proxy.py @@ -73,7 +73,7 @@ class ProxyModule(HasIO, Module): props = remoteparams.get(pname, None) if props is None: 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 dt = props['datatype'] try: @@ -81,28 +81,28 @@ class ProxyModule(HasIO, Module): dt.compatible(pobj.datatype) else: 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) try: dt.compatible(pobj.datatype) except Exception: - self.log.warning('remote parameter %s:%s is not fully compatible: %r != %r' - % (self.module, pname, pobj.datatype, dt)) + self.log.warning('remote parameter %s:%s is not fully compatible: %r != %r', + self.module, pname, pobj.datatype, dt) except Exception: - self.log.warning('remote parameter %s:%s has an incompatible datatype: %r != %r' - % (self.module, pname, pobj.datatype, dt)) + self.log.warning('remote parameter %s:%s has an incompatible datatype: %r != %r', + self.module, pname, pobj.datatype, dt) while cmds: cname, cobj = cmds.popitem() props = remotecmds.get(cname) 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 dt = props['datatype'] try: cobj.datatype.compatible(dt) except BadValueError: - self.log.warning('remote command %s:%s is not compatible: %r != %r' - % (self.module, cname, cobj.datatype, dt)) + self.log.warning('remote command %s:%s is not compatible: %r != %r', + self.module, cname, cobj.datatype, dt) # what to do if descriptive data does not match? # we might raise an exception, but this would lead to a reconnection, # which might not help. diff --git a/frappy/server.py b/frappy/server.py index a3fd319..87fbac0 100644 --- a/frappy/server.py +++ b/frappy/server.py @@ -211,7 +211,7 @@ class Server: missing_super = set() # all objs created, now start them up and interconnect 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) # also call earlyInit on the modules modobj.earlyInit() @@ -278,7 +278,7 @@ class Server: if not start_events.wait(): # some timeout happened 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') history_path = os.environ.get('FRAPPY_HISTORY') if history_path: diff --git a/frappy/simulation.py b/frappy/simulation.py index f3918cf..c5159b8 100644 --- a/frappy/simulation.py +++ b/frappy/simulation.py @@ -42,13 +42,13 @@ class SimBase: default=0.0) def reader(self, pname=k): - self.log.debug('simulated reading %s' % pname) + self.log.debug('simulated reading %s', pname) return self.parameters[pname].value attrs['read_' + k] = reader 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 return newval diff --git a/frappy_demo/cryo.py b/frappy_demo/cryo.py index 0b1a82c..c996422 100644 --- a/frappy_demo/cryo.py +++ b/frappy_demo/cryo.py @@ -237,8 +237,8 @@ class Cryostat(CryoBase): heater = self.heater heatflow = self.__heatLink(regulation, sample) - self.log.debug('sample = %.5f, regulation = %.5f, heatflow = %.5g' - % (sample, regulation, heatflow)) + self.log.debug('sample = %.5f, regulation = %.5f, heatflow = %.5g', + sample, regulation, heatflow) newsample = max(0, sample + (self.__sampleLeak(sample) - heatflow) / self.__sampleCP(sample) * h) # avoid instabilities due to too small CP @@ -293,7 +293,7 @@ class Cryostat(CryoBase): lastD = _D 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 -> # increase damper @@ -321,8 +321,8 @@ class Cryostat(CryoBase): try: self.setpoint = round(self.setpoint + clamp( self.target - self.setpoint, -maxdelta, maxdelta), 3) - self.log.debug('setpoint changes to %r (target %r)' % - (self.setpoint, self.target)) + self.log.debug('setpoint changes to %r (target %r)', + self.setpoint, self.target) except (TypeError, ValueError): # self.target might be None pass diff --git a/frappy_demo/modules.py b/frappy_demo/modules.py index 1840072..6ae54d7 100644 --- a/frappy_demo/modules.py +++ b/frappy_demo/modules.py @@ -169,12 +169,12 @@ class MagneticField(Drivable): if self._state == self._state.enum.switch_on: # wait until switch is 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._state = self._state.enum.ramp if self._state == self._state.enum.ramp: 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: self.log.debug('at field -> switching heater off') self._state = self._state.enum.switch_off @@ -190,7 +190,7 @@ class MagneticField(Drivable): if self._state == self._state.enum.switch_off: # wait until switch is 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.read_status() # update async time.sleep(max(0.01, ts + loopdelay - time.time())) diff --git a/frappy_mlz/amagnet.py b/frappy_mlz/amagnet.py index f88330a..3517c42 100644 --- a/frappy_mlz/amagnet.py +++ b/frappy_mlz/amagnet.py @@ -162,7 +162,7 @@ class GarfieldMagnet(SequencerMixin, Drivable): minslope = min(entry[0] for entry in self.calibrationtable.values()) self.log.error( - 'unconfigured calibration for symmetry %r' % + 'unconfigured calibration for symmetry %r', self._symmetry.value) return [minslope, 0, 0, 0, 0] diff --git a/frappy_psi/ppms.py b/frappy_psi/ppms.py index a624b69..bd210c6 100644 --- a/frappy_psi/ppms.py +++ b/frappy_psi/ppms.py @@ -386,10 +386,10 @@ class Temp(PpmsDrivable): return self.setpoint, self.workingramp, self.approachmode = self._last_settings = settings 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 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 def _write_params(self, setpoint, ramp, approachmode): @@ -407,7 +407,7 @@ class Temp(PpmsDrivable): self._ramp_at_limit = ramp_at_limit self.calc_expected(setpoint, ramp) 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.read_params() @@ -465,7 +465,7 @@ class Temp(PpmsDrivable): self.status = (StatusType.BUSY, 'changed target') self._last_change = time.time() 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 def write_approachmode(self, value): diff --git a/frappy_psi/trinamic.py b/frappy_psi/trinamic.py index c0e706d..af7cb34 100644 --- a/frappy_psi/trinamic.py +++ b/frappy_psi/trinamic.py @@ -213,7 +213,7 @@ class Motor(PersistentMixin, HasIO, Drivable): self.log.error('saved encoder value (%.2f) does not match reading (%.2f %.2f)', self.encoder, encoder_from_hw, adjusted_encoder) 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.status = ERROR, 'saved encoder value does not match reading' self._write_axispar(adjusted_encoder - self.zero, ENCODER_ADR, ANGLE_SCALE, readback=False)