klippy: stats() method must check that mcu and toolhead classes exist

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2016-12-01 16:51:20 -05:00
parent 71b4923208
commit 00b40b720f
1 changed files with 10 additions and 5 deletions

View File

@ -99,7 +99,9 @@ class Printer:
out = []
out.append(self.gcode.stats(eventtime))
toolhead = self.objects.get('toolhead')
if toolhead is not None:
out.append(toolhead.stats(eventtime))
if self.mcu is not None:
out.append(self.mcu.stats(eventtime))
logging.info("Stats %.0f: %s" % (eventtime, ' '.join(out)))
return eventtime + 1.
@ -186,9 +188,12 @@ class Printer:
self.gcode.set_printer_ready(False)
self.gcode.motor_heater_off()
def disconnect(self):
try:
if self.mcu is not None:
self.stats(time.time())
self.mcu.disconnect()
except:
logging.exception("Unhandled exception during disconnect")
def request_restart(self):
self.run_result = "restart"
self.reactor.end()