Compare commits

4 Commits

Author SHA1 Message Date
n07070
175dd3385a Add content in print queue method 2026-06-04 02:32:47 +02:00
n07070
3a1d9b20fb Add skip line and catch printing errors 2026-06-04 02:32:23 +02:00
n07070
c57e2f91a2 Update getting debug env 2026-06-04 02:32:08 +02:00
n07070
9ccd2b8bdf Use textarea instead of input, easier for ASCII art 2026-06-04 02:31:53 +02:00
4 changed files with 28 additions and 22 deletions

View File

@@ -83,7 +83,7 @@ except PermissionError:
sys.exit(77)
# Output the config file
if os.getenv("FLASK_DEBUG"):
if not os.getenv("FLASK_DEBUG") is None and os.getenv("FLASK_DEBUG") is True:
pprint.pprint(configuration_file)
# We define the app module used by Flask
@@ -402,4 +402,4 @@ def camera_status():
if __name__ == "__main__":
app.run(debug=True, use_reloader=False, host="0.0.0.0", ssl_context="adhoc")
app.run(use_reloader=False, host="0.0.0.0", ssl_context="adhoc")

View File

@@ -77,7 +77,7 @@ class PrintQueue:
with self._lock:
self.app.logger.debug("Return current queue state")
return [
{"task_id": t.task_id, "status": t.status, "type": str(t.task_type)}
{"task_id": t.task_id, "status": t.status, "type": str(t.task_type), "content": str(t.get_print_data())}
for t in self._queue
]

View File

@@ -216,6 +216,7 @@ class EscPosPrinter(Printer):
self.printer.textln(clean_msg)
if clean_signature:
self.printer.textln(clean_signature)
self.printer.textln()
self.printer.close()
except Exception as e:
self.app.logger.error("Unable to print because : " + str(e))
@@ -323,6 +324,7 @@ class EscPosPrinter(Printer):
with self._lock:
if self._state:
self._state = False
try:
match (task_type.value):
case "text":
self._print_txt(data["txt"], signature=data["sign"])
@@ -340,7 +342,10 @@ class EscPosPrinter(Printer):
self._state = True
case _:
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 !")

View File

@@ -6,7 +6,8 @@
<h3 class="card-header">Print a short message</h3>
<div class="card-body">
<form class="form-group" action="/web/print/sms" method="post">
<input class="form-control" type="text" name="txt" placeholder="200 chars or less " maxlength="200" required><br>
<textarea class="form-control" type="text" name="txt" placeholder="4096 chars or less " maxlength="4096"></textarea>
<br>
<input class="form-control" type="text" name="signature" placeholder="Signature or pseudo" maxlength="200"><br>
<input class="btn btn-primary float-right" type="submit" value="Imprimer" name="imprimer">
</form>