Change the way cuts are managed, rewrite lock mechanism, add support for

multiple printers
This commit is contained in:
n07070 committed 2026-11-28 00:54:15 +01:00
1 parent aa1f9d1532
commit 52205be6af
8 files changed
+439 -322

No files matched your search

+9 -14
View File
@@ -5,7 +5,7 @@ Manage all of the inputs from a web source
import os
from werkzeug.utils import secure_filename
import uuid
from task import TextTask, ImageTask, CutTask
from task import TextTask, ImageTask
class Web:
@@ -30,12 +30,9 @@ class Web:
# are added back to back, another task could be
# inserted between the two.
for i in range(many):
sms = self.print_queue.enqueue(TextTask(content=texte, signature=sign))
self.app.logger.info("Added a SMS task at position %s", sms)
if do_cut:
cut = self.print_queue.enqueue(CutTask())
self.app.logger.info("Added a CUT task at position %s", cut)
sms = self.print_queue.enqueue(TextTask(content=texte, signature=sign, do_cut=do_cut))
self.app.logger.info("Added a SMS task at position %s, it should %scut", sms, "" if not do_cut else "not ")
self.app.logger.debug("%s", do_cut)
except Exception as e:
self.app.logger.error(e)
raise RuntimeError("Could not add SMS to queue, " + str(e)) from e
@@ -44,7 +41,7 @@ class Web:
def print_image(
self, image, sign: str, do_cut: bool, process_image: bool, many: int = 1
) -> bool:
) -> bool:
"""
Get an image and a signature, prints the image and cuts after that.
"""
@@ -69,16 +66,14 @@ class Web:
),
signature=sign,
process=process_image,
task_id=image_uuid
task_id=str(uuid.uuid4()),
do_cut=do_cut
)
)
self.app.logger.info("Added a IMG task at position %s", img)
self.app.logger.info("Added a IMG task at position %s, it should %s cut", img, "not " if not do_cut else "")
if do_cut:
cut = self.print_queue.enqueue(CutTask())
self.app.logger.info("Added a CUT task at position %s", cut)
except Exception as e:
raise RuntimeError("Could not add IMG to queue" + str(e)) from e
raise RuntimeError("Could not add IMG to queue " + str(e)) from e
return True