From 797367b9f5652df4103d7185567c8d749a8afbff Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 8 Jan 2019 10:55:18 -0500 Subject: klippy: Convert printer_state("ready") to an event handler Convert all users of the printer_state("ready") handler to register a "klippy:ready" event handler instead. Signed-off-by: Kevin O'Connor --- klippy/extras/statistics.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'klippy/extras/statistics.py') diff --git a/klippy/extras/statistics.py b/klippy/extras/statistics.py index 639bcad3..84186ed1 100644 --- a/klippy/extras/statistics.py +++ b/klippy/extras/statistics.py @@ -11,13 +11,13 @@ class PrinterStats: reactor = self.printer.get_reactor() self.stats_timer = reactor.register_timer(self.generate_stats) self.stats_cb = [] - def printer_state(self, state): - if state == 'ready': - self.stats_cb = [o.stats for n, o in self.printer.lookup_objects() - if hasattr(o, 'stats')] - if self.printer.get_start_args().get('debugoutput') is None: - reactor = self.printer.get_reactor() - reactor.update_timer(self.stats_timer, reactor.NOW) + self.printer.register_event_handler("klippy:ready", self.handle_ready) + def handle_ready(self): + self.stats_cb = [o.stats for n, o in self.printer.lookup_objects() + if hasattr(o, 'stats')] + if self.printer.get_start_args().get('debugoutput') is None: + reactor = self.printer.get_reactor() + reactor.update_timer(self.stats_timer, reactor.NOW) def generate_stats(self, eventtime): stats = [cb(eventtime) for cb in self.stats_cb] if max([s[0] for s in stats]): -- cgit v1.2.3-70-g09d2