Compare commits
4 Commits
54678175ba
...
175dd3385a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
175dd3385a | ||
|
|
3a1d9b20fb | ||
|
|
c57e2f91a2 | ||
|
|
9ccd2b8bdf |
@@ -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")
|
||||
|
||||
@@ -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
|
||||
]
|
||||
|
||||
|
||||
@@ -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,24 +324,28 @@ class EscPosPrinter(Printer):
|
||||
with self._lock:
|
||||
if self._state:
|
||||
self._state = False
|
||||
match (task_type.value):
|
||||
case "text":
|
||||
self._print_txt(data["txt"], signature=data["sign"])
|
||||
self._state = True
|
||||
case "image":
|
||||
self._print_img(
|
||||
data["img"], signature=data["sign"], process=data["process"]
|
||||
)
|
||||
self._state = True
|
||||
case "cut":
|
||||
self._cut()
|
||||
self._state = True
|
||||
case "qr":
|
||||
self._qr(data["txt"])
|
||||
self._state = True
|
||||
case _:
|
||||
raise RuntimeError("This task type is not supported")
|
||||
else:
|
||||
try:
|
||||
match (task_type.value):
|
||||
case "text":
|
||||
self._print_txt(data["txt"], signature=data["sign"])
|
||||
self._state = True
|
||||
case "image":
|
||||
self._print_img(
|
||||
data["img"], signature=data["sign"], process=data["process"]
|
||||
)
|
||||
self._state = True
|
||||
case "cut":
|
||||
self._cut()
|
||||
self._state = True
|
||||
case "qr":
|
||||
self._qr(data["txt"])
|
||||
self._state = True
|
||||
case _:
|
||||
raise RuntimeError("This task type is not supported")
|
||||
except Exception as e:
|
||||
self._state = True
|
||||
raise RuntimeError from e
|
||||
|
||||
raise RuntimeError("The printer is not ready to print yet !")
|
||||
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user