aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArksine <arksine.code@gmail.com>2020-10-28 08:42:17 -0400
committerKevinOConnor <kevin@koconnor.net>2020-11-04 18:32:30 -0500
commit8a5e7d8d284057c8d643d2a299fd0bc3f7ed3629 (patch)
tree16e6124537e0072e9e7cda44853eac55760f53b1
parent108b66efe941c624f2d713c4c37de49fdae54282 (diff)
downloadkutter-8a5e7d8d284057c8d643d2a299fd0bc3f7ed3629.tar.gz
kutter-8a5e7d8d284057c8d643d2a299fd0bc3f7ed3629.tar.xz
kutter-8a5e7d8d284057c8d643d2a299fd0bc3f7ed3629.zip
gcode_macro: implement "action_call_remote_method" context action
Users may use this action to call methods registered by a webhooks client from a command template. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
-rw-r--r--klippy/extras/gcode_macro.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/klippy/extras/gcode_macro.py b/klippy/extras/gcode_macro.py
index 1cc3a5a1..aae5f3bb 100644
--- a/klippy/extras/gcode_macro.py
+++ b/klippy/extras/gcode_macro.py
@@ -87,12 +87,20 @@ class PrinterGCodeMacro:
return ""
def _action_raise_error(self, msg):
raise self.printer.command_error(msg)
+ def _action_call_remote_method(self, method, **kwargs):
+ webhooks = self.printer.lookup_object('webhooks')
+ try:
+ webhooks.call_remote_method(method, **kwargs)
+ except self.printer.command_error:
+ logging.exception("Remote Call Error")
+ return ""
def create_template_context(self, eventtime=None):
return {
'printer': GetStatusWrapper(self.printer, eventtime),
'action_emergency_stop': self._action_emergency_stop,
'action_respond_info': self._action_respond_info,
'action_raise_error': self._action_raise_error,
+ 'action_call_remote_method': self._action_call_remote_method,
}
def load_config(config):