klippy: Avoid using '%' syntax when calling logging module
The logging module can build strings directly from printf syntax - no need to build the string first. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
8f8951b4c1
commit
8d5a9143bb
|
@ -90,7 +90,7 @@ def check_build_code(srcdir, target, sources, cmd, other_files=[]):
|
|||
src_times = get_mtimes(srcdir, sources + other_files)
|
||||
obj_times = get_mtimes(srcdir, [target])
|
||||
if not obj_times or max(src_times) > min(obj_times):
|
||||
logging.info("Building C code module %s" % (target,))
|
||||
logging.info("Building C code module %s", target)
|
||||
srcfiles = [os.path.join(srcdir, fname) for fname in sources]
|
||||
destlib = os.path.join(srcdir, target)
|
||||
os.system(cmd % (destlib, ' '.join(srcfiles)))
|
||||
|
|
|
@ -148,9 +148,9 @@ class PrinterHeater:
|
|||
pwm_time = read_time + REPORT_TIME + SAMPLE_TIME*SAMPLE_COUNT
|
||||
self.next_pwm_time = pwm_time + 0.75 * MAX_HEAT_TIME
|
||||
self.last_pwm_value = value
|
||||
logging.debug("%s: pwm=%.3f@%.3f (from %.3f@%.3f [%.3f])" % (
|
||||
logging.debug("%s: pwm=%.3f@%.3f (from %.3f@%.3f [%.3f])",
|
||||
self.name, value, pwm_time,
|
||||
self.last_temp, self.last_temp_time, self.target_temp))
|
||||
self.last_temp, self.last_temp_time, self.target_temp)
|
||||
self.mcu_pwm.set_pwm(pwm_time, value)
|
||||
def adc_callback(self, read_time, read_value):
|
||||
temp = self.sensor.calc_temp(read_value)
|
||||
|
@ -159,7 +159,7 @@ class PrinterHeater:
|
|||
self.last_temp_time = read_time
|
||||
self.can_extrude = (temp >= self.min_extrude_temp)
|
||||
self.control.adc_callback(read_time, temp)
|
||||
#logging.debug("temp: %.3f %f = %f" % (read_time, read_value, temp))
|
||||
#logging.debug("temp: %.3f %f = %f", read_time, read_value, temp)
|
||||
# External commands
|
||||
def set_temp(self, print_time, degrees):
|
||||
if degrees and (degrees < self.min_temp or degrees > self.max_temp):
|
||||
|
@ -239,8 +239,8 @@ class ControlPID:
|
|||
temp_integ = max(0., min(self.temp_integ_max, temp_integ))
|
||||
# Calculate output
|
||||
co = self.Kp*temp_err + self.Ki*temp_integ - self.Kd*temp_deriv
|
||||
#logging.debug("pid: %f@%.3f -> diff=%f deriv=%f err=%f integ=%f co=%d" % (
|
||||
# temp, read_time, temp_diff, temp_deriv, temp_err, temp_integ, co))
|
||||
#logging.debug("pid: %f@%.3f -> diff=%f deriv=%f err=%f integ=%f co=%d",
|
||||
# temp, read_time, temp_diff, temp_deriv, temp_err, temp_integ, co)
|
||||
bounded_co = max(0., min(self.heater.max_power, co))
|
||||
self.heater.set_pwm(read_time, bounded_co)
|
||||
# Store state for next measurement
|
||||
|
@ -305,9 +305,9 @@ class ControlAutoTune:
|
|||
Td = 0.125 * Tu
|
||||
Ki = Kp / Ti
|
||||
Kd = Kp * Td
|
||||
logging.info("Autotune: raw=%f/%f Ku=%f Tu=%f Kp=%f Ki=%f Kd=%f" % (
|
||||
temp_diff, max_power, Ku, Tu,
|
||||
Kp * PID_PARAM_BASE, Ki * PID_PARAM_BASE, Kd * PID_PARAM_BASE))
|
||||
logging.info("Autotune: raw=%f/%f Ku=%f Tu=%f Kp=%f Ki=%f Kd=%f",
|
||||
temp_diff, max_power, Ku, Tu, Kp * PID_PARAM_BASE,
|
||||
Ki * PID_PARAM_BASE, Kd * PID_PARAM_BASE)
|
||||
def check_busy(self, eventtime):
|
||||
if self.heating or len(self.peaks) < 12:
|
||||
return True
|
||||
|
|
|
@ -159,7 +159,7 @@ class Printer:
|
|||
out.append(toolhead.stats(eventtime))
|
||||
for m in self.mcus:
|
||||
out.append(m.stats(eventtime))
|
||||
logging.info("Stats %.1f: %s" % (eventtime, ' '.join(out)))
|
||||
logging.info("Stats %.1f: %s", eventtime, ' '.join(out))
|
||||
return eventtime + 1.
|
||||
def add_object(self, name, obj):
|
||||
self.objects[name] = obj
|
||||
|
@ -217,8 +217,8 @@ class Printer:
|
|||
def run(self):
|
||||
systime = time.time()
|
||||
monotime = self.reactor.monotonic()
|
||||
logging.info("Start printer at %s (%.1f %.1f)" % (
|
||||
time.asctime(time.localtime(systime)), systime, monotime))
|
||||
logging.info("Start printer at %s (%.1f %.1f)",
|
||||
time.asctime(time.localtime(systime)), systime, monotime)
|
||||
# Enter main reactor loop
|
||||
try:
|
||||
self.reactor.run()
|
||||
|
|
|
@ -208,7 +208,7 @@ class MessageParser:
|
|||
msgcrc = s[msglen-MESSAGE_TRAILER_CRC:msglen-MESSAGE_TRAILER_CRC+2]
|
||||
crc = crc16_ccitt(s[:msglen-MESSAGE_TRAILER_SIZE])
|
||||
if crc != msgcrc:
|
||||
#logging.debug("got crc %s vs %s" % (repr(crc), repr(msgcrc)))
|
||||
#logging.debug("got crc %s vs %s", repr(crc), repr(msgcrc))
|
||||
return -1
|
||||
return msglen
|
||||
def dump(self, s):
|
||||
|
|
|
@ -63,7 +63,7 @@ class SerialReader:
|
|||
else:
|
||||
self.ser = open(self.serialport, 'rb+')
|
||||
except (OSError, IOError, serial.SerialException) as e:
|
||||
logging.warn("Unable to open port: %s" % (e,))
|
||||
logging.warn("Unable to open port: %s", e)
|
||||
self.reactor.pause(starttime + 5.)
|
||||
continue
|
||||
if self.baud:
|
||||
|
@ -84,10 +84,10 @@ class SerialReader:
|
|||
msgparser.process_identify(identify_data)
|
||||
self.msgparser = msgparser
|
||||
self.register_callback(self.handle_unknown, '#unknown')
|
||||
logging.info("Loaded %d commands (%s)" % (
|
||||
len(msgparser.messages_by_id), msgparser.version))
|
||||
logging.info("MCU config: %s" % (" ".join(
|
||||
["%s=%s" % (k, v) for k, v in msgparser.config.items()])))
|
||||
logging.info("Loaded %d commands (%s)",
|
||||
len(msgparser.messages_by_id), msgparser.version)
|
||||
logging.info("MCU config: %s", " ".join(
|
||||
["%s=%s" % (k, v) for k, v in msgparser.config.items()]))
|
||||
# Setup baud adjust
|
||||
mcu_baud = float(msgparser.config.get('SERIAL_BAUD', 0.))
|
||||
if mcu_baud:
|
||||
|
@ -165,12 +165,12 @@ class SerialReader:
|
|||
return '\n'.join(out)
|
||||
# Default message handlers
|
||||
def handle_unknown(self, params):
|
||||
logging.warn("Unknown message type %d: %s" % (
|
||||
params['#msgid'], repr(params['#msg'])))
|
||||
logging.warn("Unknown message type %d: %s",
|
||||
params['#msgid'], repr(params['#msg']))
|
||||
def handle_output(self, params):
|
||||
logging.info("%s: %s" % (params['#name'], params['#msg']))
|
||||
logging.info("%s: %s", params['#name'], params['#msg'])
|
||||
def handle_default(self, params):
|
||||
logging.warn("got %s" % (params,))
|
||||
logging.warn("got %s", params)
|
||||
def __del__(self):
|
||||
self.disconnect()
|
||||
|
||||
|
@ -249,8 +249,8 @@ class SerialBootStrap:
|
|||
self.serial.send(imsg)
|
||||
return eventtime + self.RETRY_TIME
|
||||
def handle_unknown(self, params):
|
||||
logging.debug("Unknown message %d (len %d) while identifying" % (
|
||||
params['#msgid'], len(params['#msg'])))
|
||||
logging.debug("Unknown message %d (len %d) while identifying",
|
||||
params['#msgid'], len(params['#msg']))
|
||||
|
||||
# Attempt to place an AVR stk500v2 style programmer into normal mode
|
||||
def stk500v2_leave(ser, reactor):
|
||||
|
@ -267,7 +267,7 @@ def stk500v2_leave(ser, reactor):
|
|||
ser.write('\x1b\x01\x00\x01\x0e\x11\x04')
|
||||
reactor.pause(reactor.monotonic() + 0.050)
|
||||
res = ser.read(4096)
|
||||
logging.debug("Got %s from stk500v2" % (repr(res),))
|
||||
logging.debug("Got %s from stk500v2", repr(res))
|
||||
ser.baudrate = origbaud
|
||||
|
||||
# Attempt an arduino style reset on a serial port
|
||||
|
|
|
@ -91,7 +91,7 @@ class PrinterHomingStepper(PrinterStepper):
|
|||
endstop_accuracy * self.inv_step_dist))
|
||||
if self.homing_endstop_accuracy >= self.homing_stepper_phases // 2:
|
||||
logging.info("Endstop for %s is not accurate enough for stepper"
|
||||
" phase adjustment" % (name,))
|
||||
" phase adjustment", name)
|
||||
self.homing_stepper_phases = None
|
||||
if self.mcu_endstop.get_mcu().is_fileoutput():
|
||||
self.homing_endstop_accuracy = self.homing_stepper_phases
|
||||
|
@ -108,7 +108,7 @@ class PrinterHomingStepper(PrinterStepper):
|
|||
pos = self.mcu_stepper.get_mcu_position()
|
||||
pos %= self.homing_stepper_phases
|
||||
if self.homing_endstop_phase is None:
|
||||
logging.info("Setting %s endstop phase to %d" % (self.name, pos))
|
||||
logging.info("Setting %s endstop phase to %d", self.name, pos)
|
||||
self.homing_endstop_phase = pos
|
||||
return 0
|
||||
delta = (pos - self.homing_endstop_phase) % self.homing_stepper_phases
|
||||
|
|
|
@ -339,7 +339,7 @@ class ToolHead:
|
|||
self.extruder.motor_off(last_move_time)
|
||||
self.dwell(STALL_TIME)
|
||||
self.need_motor_off = False
|
||||
logging.debug('; Max time of %f' % (last_move_time,))
|
||||
logging.debug('; Max time of %f', last_move_time)
|
||||
def wait_moves(self):
|
||||
self._flush_lookahead()
|
||||
if self.mcu.is_fileoutput():
|
||||
|
|
|
@ -43,8 +43,8 @@ def get_cpu_info():
|
|||
data = f.read()
|
||||
f.close()
|
||||
except OSError:
|
||||
logging.debug("Exception on read /proc/cpuinfo: %s" % (
|
||||
traceback.format_exc(),))
|
||||
logging.debug("Exception on read /proc/cpuinfo: %s",
|
||||
traceback.format_exc())
|
||||
return "?"
|
||||
lines = [l.split(':', 1) for l in data.split('\n')]
|
||||
lines = [(l[0].strip(), l[1].strip()) for l in lines if len(l) == 2]
|
||||
|
@ -64,6 +64,6 @@ def get_git_version():
|
|||
output = process.communicate()[0]
|
||||
retcode = process.poll()
|
||||
except OSError:
|
||||
logging.debug("Exception on run: %s" % (traceback.format_exc(),))
|
||||
logging.debug("Exception on run: %s", traceback.format_exc())
|
||||
return "?"
|
||||
return output.strip()
|
||||
|
|
Loading…
Reference in New Issue