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 <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-01-08 12:00:45 -05:00
parent 33f5b5f285
commit bf647749dd
1 changed files with 5 additions and 7 deletions

View File

@ -1049,13 +1049,11 @@ class MenuManager:
def handle_ready(self): def handle_ready(self):
# Load all available printer objects # Load all available printer objects
for cfg_name in self.printer.objects: for cfg_name, obj in self.printer.lookup_objects():
obj = self.printer.lookup_object(cfg_name, None) name = ".".join(str(cfg_name).split())
if obj is not None: self.objs[name] = obj
name = ".".join(str(cfg_name).split()) logging.debug("Load module '%s' -> %s" % (
self.objs[name] = obj str(name), str(obj.__class__)))
logging.debug("Load module '%s' -> %s" % (
str(name), str(obj.__class__)))
# start timer # start timer
reactor = self.printer.get_reactor() reactor = self.printer.get_reactor()
reactor.register_timer(self.timer_event, reactor.NOW) reactor.register_timer(self.timer_event, reactor.NOW)