Update configuration options in the web methods
This commit is contained in:
1 parent
8309399827
commit
836d6b0be9
2 files changed
+38
-28
No files matched your search
+22
-20
@@ -16,7 +16,7 @@ class Web:
|
||||
self.print_queue = print_queue
|
||||
self.app = app
|
||||
|
||||
def print_sms(self, texte, sign: str, do_cut: bool) -> bool:
|
||||
def print_sms(self, texte, sign: str, do_cut: bool, many: int = 1) -> bool:
|
||||
"""
|
||||
Get text and a signature, prints the text and cuts after that.
|
||||
"""
|
||||
@@ -28,19 +28,20 @@ class Web:
|
||||
# !! there is no garantee !! that both the SMS task and the Cut task
|
||||
# are added back to back, another task could be
|
||||
# inserted between the two.
|
||||
sms = self.print_queue.enqueue(TextTask(content=texte, signature=sign))
|
||||
self.app.logger.info("Added a SMS task at position %s", sms)
|
||||
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)
|
||||
|
||||
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:
|
||||
self.app.logger.error(e)
|
||||
raise RuntimeError("Could not add SMS to queue, " + str(e)) from e
|
||||
|
||||
return True
|
||||
|
||||
def print_image(self, image, sign: str, do_cut: bool, process_image: bool) -> bool:
|
||||
def print_image(self, image, sign: str, do_cut: bool, process_image: bool, many: int = 1) -> bool:
|
||||
"""
|
||||
Get an image and a signature, prints the image and cuts after that.
|
||||
"""
|
||||
@@ -53,21 +54,22 @@ class Web:
|
||||
if file_uploaded:
|
||||
self.app.logger.debug("File has been uploaded, printing...")
|
||||
try:
|
||||
img = self.print_queue.enqueue(
|
||||
ImageTask(
|
||||
os.path.join(
|
||||
self.app.config["UPLOAD_FOLDER"],
|
||||
secure_filename(image.filename),
|
||||
),
|
||||
signature=sign,
|
||||
process=process_image,
|
||||
for i in range(many):
|
||||
img = self.print_queue.enqueue(
|
||||
ImageTask(
|
||||
os.path.join(
|
||||
self.app.config["UPLOAD_FOLDER"],
|
||||
secure_filename(image.filename),
|
||||
),
|
||||
signature=sign,
|
||||
process=process_image,
|
||||
)
|
||||
)
|
||||
)
|
||||
self.app.logger.info("Added a IMG task at position %s", img)
|
||||
self.app.logger.info("Added a IMG task at position %s", img)
|
||||
|
||||
if do_cut:
|
||||
cut = self.print_queue.enqueue(CutTask())
|
||||
self.app.logger.info("Added a CUT task at position %s", cut)
|
||||
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
|
||||
|
||||
|
||||
Reference in new issue
Block a user