From a260356d78fe118db243e803ead64ec406d6fdbc Mon Sep 17 00:00:00 2001 From: Arksine Date: Mon, 9 Nov 2020 07:01:38 -0500 Subject: [PATCH] klippy_apis: update request handlers to accept WebRequest objects Signed-off-by: Eric Callahan --- moonraker/plugins/klippy_apis.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/moonraker/plugins/klippy_apis.py b/moonraker/plugins/klippy_apis.py index 84e5f44..38106d8 100644 --- a/moonraker/plugins/klippy_apis.py +++ b/moonraker/plugins/klippy_apis.py @@ -4,6 +4,7 @@ # # This file may be distributed under the terms of the GNU GPLv3 license. import utils +from websockets import WebRequest INFO_ENDPOINT = "info" ESTOP_ENDPOINT = "emergency_stop" @@ -36,28 +37,29 @@ class KlippyAPI: self.server.register_endpoint( "/printer/firmware_restart", ['POST'], self._gcode_firmware_restart) - async def _gcode_pause(self, path, method, args): + async def _gcode_pause(self, web_request): return await self.run_gcode("PAUSE") - async def _gcode_resume(self, path, method, args): + async def _gcode_resume(self, web_request): return await self.run_gcode("RESUME") - async def _gcode_cancel(self, path, method, args): + async def _gcode_cancel(self, web_request): return await self.run_gcode("CANCEL_PRINT") - async def _gcode_start_print(self, path, method, args): - filename = args.get('filename') + async def _gcode_start_print(self, web_request): + filename = web_request.get_str('filename') return await self.start_print(filename) - async def _gcode_restart(self, path, method, args): + async def _gcode_restart(self, web_request): return await self.do_restart("RESTART") - async def _gcode_firmware_restart(self, path, method, args): + async def _gcode_firmware_restart(self, web_request): return await self.do_restart("FIRMWARE_RESTART") async def _send_klippy_request(self, method, params, default=Sentinel): try: - result = await self.server.make_request(method, params) + result = await self.server.make_request( + WebRequest(method, params)) except self.server.error as e: if default == Sentinel: raise