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:
Arksine 2020-08-11 20:43:20 -04:00
parent 2c332a968f
commit e78a2e3e41
1 changed files with 12 additions and 2 deletions

View File

@ -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)