From bf647749dd3eeaa6da57b64ed122c2be42ed58e7 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 8 Jan 2019 12:00:45 -0500 Subject: [PATCH] menu: Don't peek into printer.objects member variable Use the printer.lookup_objects() method to get the list of available printer objects. Signed-off-by: Kevin O'Connor --- klippy/extras/display/menu.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/klippy/extras/display/menu.py b/klippy/extras/display/menu.py index 470a2078..e6304e39 100644 --- a/klippy/extras/display/menu.py +++ b/klippy/extras/display/menu.py @@ -1049,13 +1049,11 @@ class MenuManager: def handle_ready(self): # Load all available printer objects - for cfg_name in self.printer.objects: - obj = self.printer.lookup_object(cfg_name, None) - if obj is not None: - name = ".".join(str(cfg_name).split()) - self.objs[name] = obj - logging.debug("Load module '%s' -> %s" % ( - str(name), str(obj.__class__))) + for cfg_name, obj in self.printer.lookup_objects(): + name = ".".join(str(cfg_name).split()) + self.objs[name] = obj + logging.debug("Load module '%s' -> %s" % ( + str(name), str(obj.__class__))) # start timer reactor = self.printer.get_reactor() reactor.register_timer(self.timer_event, reactor.NOW)