gcode_apis: handle restart exceptions
It is expected that the Klippy will disconnect when a restart request is sent. Handle those exceptions so they return an acknowledgement. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
2c332a968f
commit
e78a2e3e41
|
@ -58,10 +58,20 @@ class GCodeAPIs:
|
|||
return await self._send_gcode(script)
|
||||
|
||||
async def gcode_restart(self, path, method, args):
|
||||
return await self._send_gcode("RESTART")
|
||||
return await self._do_restart("RESTART")
|
||||
|
||||
async def gcode_firmware_restart(self, path, method, args):
|
||||
return await self._send_gcode("FIRMWARE_RESTART")
|
||||
return await self._do_restart("FIRMWARE_RESTART")
|
||||
|
||||
async def _do_restart(self, gc):
|
||||
try:
|
||||
result = await self._send_gcode(gc)
|
||||
except self.server.error as e:
|
||||
if str(e) == "Klippy Disconnected":
|
||||
result = "ok"
|
||||
else:
|
||||
raise
|
||||
return result
|
||||
|
||||
def load_plugin(config):
|
||||
return GCodeAPIs(config)
|
||||
|
|
Loading…
Reference in New Issue