From 4346d37c0662d7d0cae08968e0a5737afcd49c52 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 4 Aug 2020 16:00:23 -0400 Subject: [PATCH] webhooks: Introduce add_early_printer_objects() Create the initial gcode class via new module level add_early_printer_objects() function. Signed-off-by: Kevin O'Connor --- klippy/klippy.py | 5 +++-- klippy/webhooks.py | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/klippy/klippy.py b/klippy/klippy.py index 678c0980..6a24d4a3 100644 --- a/klippy/klippy.py +++ b/klippy/klippy.py @@ -58,8 +58,9 @@ class Printer: self.run_result = None self.event_handlers = {} self.objects = collections.OrderedDict() - self.objects['webhooks'] = webhooks.WebHooks(self) - gcode.add_early_printer_objects(self) + # Init printer components that must be setup prior to config + for m in [webhooks, gcode]: + m.add_early_printer_objects(self) def get_start_args(self): return self.start_args def get_reactor(self): diff --git a/klippy/webhooks.py b/klippy/webhooks.py index 8be225a4..1c3645be 100644 --- a/klippy/webhooks.py +++ b/klippy/webhooks.py @@ -268,3 +268,6 @@ class WebHooks: logging.info(msg) raise WebRequestError(msg) return cb + +def add_early_printer_objects(printer): + printer.add_object('webhooks', WebHooks(printer))