aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-12-01 16:51:20 -0500
committerKevin O'Connor <kevin@koconnor.net>2016-12-01 18:17:54 -0500
commit00b40b720fbc8beeb305fb0afa24ceb9443568ae (patch)
treea0f941d551069cde6eae2f351a8c7e3904ab76d6
parent71b4923208b0fda7810d923ae8e2a178030eebac (diff)
downloadkutter-00b40b720fbc8beeb305fb0afa24ceb9443568ae.tar.gz
kutter-00b40b720fbc8beeb305fb0afa24ceb9443568ae.tar.xz
kutter-00b40b720fbc8beeb305fb0afa24ceb9443568ae.zip
klippy: stats() method must check that mcu and toolhead classes exist
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/klippy.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/klippy/klippy.py b/klippy/klippy.py
index 361075b8..978d6447 100644
--- a/klippy/klippy.py
+++ b/klippy/klippy.py
@@ -99,8 +99,10 @@ class Printer:
out = []
out.append(self.gcode.stats(eventtime))
toolhead = self.objects.get('toolhead')
- out.append(toolhead.stats(eventtime))
- out.append(self.mcu.stats(eventtime))
+ 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.
def load_config(self):
@@ -186,9 +188,12 @@ class Printer:
self.gcode.set_printer_ready(False)
self.gcode.motor_heater_off()
def disconnect(self):
- if self.mcu is not None:
- self.stats(time.time())
- self.mcu.disconnect()
+ 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()