power: Raise error if trying to change a locked device during printing

Signed-off-by: Jordan Ruthe <jordan.ruthe@gmail.com>
This commit is contained in:
Jordan Ruthe 2021-01-22 09:42:09 -05:00 committed by Eric Callahan
parent 00db209d5d
commit 0b3b8cede8
1 changed files with 2 additions and 6 deletions

View File

@ -105,13 +105,9 @@ class PrinterPower:
async def _process_request(self, device, req): async def _process_request(self, device, req):
if req in ["on", "off"]: if req in ["on", "off"]:
printing = await self._check_klippy_printing() printing = await self._check_klippy_printing()
logging.info("Device locked: %s" % device.get_locked_while_printing())
logging.info("Klippy printing: %s" % printing)
if device.get_locked_while_printing() and printing: if device.get_locked_while_printing() and printing:
self.server.error(f"Unable to change power for {device} " + raise self.server.error(f"Unable to change power for {device} "
"while printing") + "while printing")
dev_info = device.get_device_info()
return dev_info['status']
ret = device.set_power(req) ret = device.set_power(req)
if asyncio.iscoroutine(ret): if asyncio.iscoroutine(ret):
await ret await ret