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>
This commit is contained in:
parent
108b66efe9
commit
8a5e7d8d28
|
@ -87,12 +87,20 @@ class PrinterGCodeMacro:
|
||||||
return ""
|
return ""
|
||||||
def _action_raise_error(self, msg):
|
def _action_raise_error(self, msg):
|
||||||
raise self.printer.command_error(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):
|
def create_template_context(self, eventtime=None):
|
||||||
return {
|
return {
|
||||||
'printer': GetStatusWrapper(self.printer, eventtime),
|
'printer': GetStatusWrapper(self.printer, eventtime),
|
||||||
'action_emergency_stop': self._action_emergency_stop,
|
'action_emergency_stop': self._action_emergency_stop,
|
||||||
'action_respond_info': self._action_respond_info,
|
'action_respond_info': self._action_respond_info,
|
||||||
'action_raise_error': self._action_raise_error,
|
'action_raise_error': self._action_raise_error,
|
||||||
|
'action_call_remote_method': self._action_call_remote_method,
|
||||||
}
|
}
|
||||||
|
|
||||||
def load_config(config):
|
def load_config(config):
|
||||||
|
|
Loading…
Reference in New Issue