Add skip line and catch printing errors

This commit is contained in:
n07070
2026-06-04 02:32:23 +02:00
parent c57e2f91a2
commit 3a1d9b20fb

View File

@@ -216,6 +216,7 @@ class EscPosPrinter(Printer):
self.printer.textln(clean_msg) self.printer.textln(clean_msg)
if clean_signature: if clean_signature:
self.printer.textln(clean_signature) self.printer.textln(clean_signature)
self.printer.textln()
self.printer.close() self.printer.close()
except Exception as e: except Exception as e:
self.app.logger.error("Unable to print because : " + str(e)) self.app.logger.error("Unable to print because : " + str(e))
@@ -323,6 +324,7 @@ class EscPosPrinter(Printer):
with self._lock: with self._lock:
if self._state: if self._state:
self._state = False self._state = False
try:
match (task_type.value): match (task_type.value):
case "text": case "text":
self._print_txt(data["txt"], signature=data["sign"]) self._print_txt(data["txt"], signature=data["sign"])
@@ -340,7 +342,10 @@ class EscPosPrinter(Printer):
self._state = True self._state = True
case _: case _:
raise RuntimeError("This task type is not supported") raise RuntimeError("This task type is not supported")
else: except Exception as e:
self._state = True
raise RuntimeError from e
raise RuntimeError("The printer is not ready to print yet !") raise RuntimeError("The printer is not ready to print yet !")