Add support for signature on brother printers
This commit is contained in:
@@ -20,6 +20,7 @@ class PrintWorker(threading.Thread):
|
||||
If a print fails, it's not retried, but will be added to a list of completed
|
||||
tasks. TODO : Change that
|
||||
"""
|
||||
|
||||
def __init__(self, app, print_queue, printers_pool):
|
||||
super().__init__(daemon=True)
|
||||
self.app = app
|
||||
@@ -51,12 +52,11 @@ class PrintWorker(threading.Thread):
|
||||
self._printer_index = (index + 1) % len(self.printers_obj)
|
||||
return printer
|
||||
|
||||
|
||||
def run(self):
|
||||
"""Background thread that processes queue items"""
|
||||
self.app.logger.debug("Worker %s started working.", threading.get_ident())
|
||||
self.app.logger.debug("Current threads : %s" , threading.active_count())
|
||||
self.app.logger.debug("Threads actives : %s " , threading.enumerate())
|
||||
self.app.logger.debug("Current threads : %s", threading.active_count())
|
||||
self.app.logger.debug("Threads actives : %s ", threading.enumerate())
|
||||
|
||||
while True:
|
||||
|
||||
@@ -73,7 +73,9 @@ class PrintWorker(threading.Thread):
|
||||
# If we do not have a printer, we try to find one
|
||||
|
||||
while self.running and self.printer is None:
|
||||
self.app.logger.debug("Trying to find a available printer for the worker.")
|
||||
self.app.logger.debug(
|
||||
"Trying to find a available printer for the worker."
|
||||
)
|
||||
self.printer = self._acquire_available_printer()
|
||||
self.app.logger.debug(
|
||||
"The worker got a %s printer and it's %s",
|
||||
@@ -81,14 +83,11 @@ class PrintWorker(threading.Thread):
|
||||
"Ready" if self.printer.ready else "Not ready",
|
||||
)
|
||||
|
||||
|
||||
if self.printer is None:
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
self.printer.use_printer()
|
||||
|
||||
|
||||
# If the printer is not ready, we wait for it to become ready.
|
||||
while not self.printer.ready:
|
||||
self.app.debug("Waiting for our printer to become ready...")
|
||||
@@ -115,7 +114,9 @@ class PrintWorker(threading.Thread):
|
||||
if task:
|
||||
try:
|
||||
self.app.logger.info("Got a new task")
|
||||
self.app.logger.debug("Got task %s %s", task.task_type, task.task_id)
|
||||
self.app.logger.debug(
|
||||
"Got task %s %s", task.task_type, task.task_id
|
||||
)
|
||||
task.status = "processing"
|
||||
|
||||
print_data = task.get_print_data()
|
||||
@@ -132,7 +133,7 @@ class PrintWorker(threading.Thread):
|
||||
task.status = "completed"
|
||||
self.print_queue.mark_completed(task.task_id, "completed")
|
||||
self.app.logger.debug(
|
||||
"Finished printing task %s " , task.task_id
|
||||
"Finished printing task %s ", task.task_id
|
||||
)
|
||||
self.state = "idle"
|
||||
|
||||
@@ -141,7 +142,7 @@ class PrintWorker(threading.Thread):
|
||||
self.state = "idle"
|
||||
self.print_queue.mark_completed(task.task_id, "failed")
|
||||
self.app.logger.error(
|
||||
"Could not print task %s because %s " , task.task_id, str(e)
|
||||
"Could not print task %s because %s ", task.task_id, str(e)
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user