From fb7fe282c80854ba06defa1cb4b49f1c9942f450 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 8 Jan 2019 09:15:40 -0500 Subject: klippy: Convert printer_state("shutdown") to an event handler Convert all users of the printer_state("shutdown") handler to register a "klippy:shutdown" event handler instead. Signed-off-by: Kevin O'Connor --- klippy/extras/virtual_sdcard.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'klippy/extras/virtual_sdcard.py') diff --git a/klippy/extras/virtual_sdcard.py b/klippy/extras/virtual_sdcard.py index 1a0fc2a8..e99e7cf4 100644 --- a/klippy/extras/virtual_sdcard.py +++ b/klippy/extras/virtual_sdcard.py @@ -8,6 +8,7 @@ import os, logging class VirtualSD: def __init__(self, config): printer = config.get_printer() + printer.register_event_handler("klippy:shutdown", self.handle_shutdown) # sdcard state sd = config.get('path') self.sdcard_dirname = os.path.normpath(os.path.expanduser(sd)) @@ -24,8 +25,8 @@ class VirtualSD: self.gcode.register_command(cmd, getattr(self, 'cmd_' + cmd)) for cmd in ['M28', 'M29', 'M30']: self.gcode.register_command(cmd, self.cmd_error) - def printer_state(self, state): - if state == 'shutdown' and self.work_timer is not None: + def handle_shutdown(self): + if self.work_timer is not None: self.must_pause_work = True try: readpos = max(self.file_position - 1024, 0) -- cgit v1.2.3-70-g09d2