aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/webhooks.py
Commit message (Collapse)AuthorAgeFilesLines
* webhooks: Improve python3 compatibilityKevin O'Connor2020-12-011-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Add "register_remote_method" endpointArksine2020-11-041-0/+29
| | | | | | This allows clients to register methods that can be called from Klipper. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* homing: Prefer printer.command_error() instead of homing.CommandError()Kevin O'Connor2020-09-041-1/+1
| | | | | | | Update callers to use the printer.command_error reference instead of directly using homing.CommandError() when raising or catching errors. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Add client_info parameter to "info" webhookKevin O'Connor2020-08-261-14/+29
| | | | | | | Allow clients to send their version info to klipper and arrange for that info to be logged. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Remove "action_" commands from get_status() callsKevin O'Connor2020-08-201-1/+1
| | | | | | | | | | | | Rename printer.gcode.action_emergency_stop() to action_emergency_stop(), printer.gcode.action_respond_info() to action_respond_info(), and printer.gcode.action_respond_error() to action_raise_error() in command templates. This simplifies the get_status() interface, as returning callable functions from that interface was confusing. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Improve type checking of api requestsKevin O'Connor2020-08-161-29/+31
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Convert to a json-rpc inspired message formatKevin O'Connor2020-08-161-21/+26
| | | | | | | | | | | | Convert to a new json message format. Requests look like: {"id":14, "method": "info", "params": {}} and responses look like: {"id": 14, "result": {}} Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Remove call_remote_method()Kevin O'Connor2020-08-161-13/+1
| | | | | | Clients will now only receive messages that they've subscribed to. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Add klippy state to webhooks get_status() methodKevin O'Connor2020-08-161-11/+4
| | | | | | | | Clients can now subscribe to the webhooks get_status() info to determine if the printer state changes. It is no longer needed to send a message to all clients on a shutdown transition. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Rework get_status() subscriptionsKevin O'Connor2020-08-161-116/+89
| | | | | | | | | Implement a new subscription system for get_status() updates. Subscriptions are per-client. After an initial update, only changes will be transmitted. Responses are only transmitted to the client that issued the subscription. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Require a subscription to receive gcode outputKevin O'Connor2020-08-161-12/+50
| | | | | | | | | | | Add a new "gcode/subscribe_output" webhook endpoint to subscribe to gcode output. Only client connections that subscribe to the gcode output will receive that output. This also moves all the gcode webhooks from gcode.py to webhooks.py and arranges for gcode.py to be initialized prior to webhooks.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Remove "method" parameter from webhook requestsKevin O'Connor2020-08-161-32/+14
| | | | | | | Don't require or use the "method" parameter of requests. This simplifies the interface. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Create StatusHandler class in add_early_printer_objects()Kevin O'Connor2020-08-161-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Remove register_static_path()Kevin O'Connor2020-08-161-29/+10
| | | | | | | | Use the "info" webhook to pass critical process information back to the caller. The remaining users of register_static_path() can get the required information via get_status() calls. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Specify server_address on klippy command-lineKevin O'Connor2020-08-161-8/+7
| | | | | | | | Don't default to "/tmp/klippy_uds" for the webhooks unix domain socket filename. Instead, require the filename to be specified on the command-line (via a new "-a" parameter). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: register gcode output handler and additional static pathsArksine2020-08-111-0/+24
| | | | Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* webhooks: Implement a send buffer for socket writesArksine2020-08-111-25/+29
| | | | | | This prevents ClientConnection.send() from blocking, removing the possibility that callers become reentrant. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* webhooks: Implement unix domain socket serverArksine2020-08-111-38/+77
| | | | Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* webhooks: Implement StatusHandler classArksine2020-08-061-1/+134
| | | | | | This class provides endpoints that allow connected hosts to fetch the state of printer objects and subscribe to state "pushed" over the connection. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* webhooks: Add call_remote_method helper functionArksine2020-08-061-0/+12
| | | | | | This may be used to execute formatted RPC calls. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* webhooks: Directly invoke printer.invoke_shutdown()Kevin O'Connor2020-08-061-2/+1
| | | | | | | No need to indirectly shutdown via the gcode class - just call printer.invoke_shutdown() directly. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Introduce add_early_printer_objects()Kevin O'Connor2020-08-061-0/+3
| | | | | | | Create the initial gcode class via new module level add_early_printer_objects() function. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: fix lambda wrapper around _process_requestArksine2020-07-131-1/+1
| | | | Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* webooks: do not connect if debuginput is enabledArksine2020-07-061-3/+3
| | | | | | Changing this check from debugoutput to debuginput allows remote applications to perform tests against Klippy without an MCU connected. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* webhooks: process request handlers using a Reactor CallbackArksine2020-07-061-17/+7
| | | | | | This prevents _process_data from blocking and becoming reentrant. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* klippy: return message category in get_state_message()Arksine2020-06-241-5/+3
| | | | Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* webhooks: protect command processing from re-entryArksine2020-06-241-4/+16
| | | | Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* webhooks: Initial implementationArksine2020-06-241-0/+270
The webhooks module provides a means for Klippy to register remote API endpoints. Signed-off-by: Eric Callahan <arksine.code@gmail.com>