From de1575f7572ad8fabbd2350623433b39868d36b7 Mon Sep 17 00:00:00 2001 From: Arksine Date: Mon, 9 Nov 2020 07:02:22 -0500 Subject: [PATCH] power: update request handlers to accept WebRequest objects Signed-off-by: Eric Callahan --- moonraker/plugins/power.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/moonraker/plugins/power.py b/moonraker/plugins/power.py index 9c7f2ed..33a13d2 100644 --- a/moonraker/plugins/power.py +++ b/moonraker/plugins/power.py @@ -38,7 +38,7 @@ class PrinterPower: ioloop = IOLoop.current() ioloop.spawn_callback(self.initialize_devices, devices) - async def _handle_list_devices(self, path, method, args): + async def _handle_list_devices(self, web_request): output = {"devices": []} for dev in self.devices: output['devices'].append({ @@ -47,15 +47,17 @@ class PrinterPower: }) return output - async def _handle_power_request(self, path, method, args): + async def _handle_power_request(self, web_request): + args = web_request.get_args() + ep = web_request.get_endpoint() if len(args) == 0: - if path == "/machine/gpio_power/status": + if ep == "/machine/gpio_power/status": args = self.devices else: return "no_devices" result = {} - req = path.split("/")[-1] + req = ep.split("/")[-1] for dev in args: if req not in ("on", "off", "status"): raise self.server.error("Unsupported power request")