klippy_apis: update request handlers to accept WebRequest objects
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
27a17ed5a6
commit
a260356d78
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue