Compare commits
5 Commits
836d6b0be9
...
multi-prin
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
070f037449 | ||
|
|
adb5e9422d | ||
|
|
d348acd88c | ||
|
|
e8568795b2 | ||
|
|
086a7ae640 |
@@ -3,6 +3,7 @@
|
|||||||
[defaults]
|
[defaults]
|
||||||
signature = ""
|
signature = ""
|
||||||
|
|
||||||
|
|
||||||
# Printer settings
|
# Printer settings
|
||||||
[printer]
|
[printer]
|
||||||
upload_folder = "src/static/uploads"
|
upload_folder = "src/static/uploads"
|
||||||
@@ -14,11 +15,14 @@ waiting_time = 5
|
|||||||
profile = "TM-T20III"
|
profile = "TM-T20III"
|
||||||
label_type = 80 # 80 or 58 ( label width in mm )
|
label_type = 80 # 80 or 58 ( label width in mm )
|
||||||
align_text = "center"
|
align_text = "center"
|
||||||
|
text_max_length = 4096
|
||||||
|
signature_max_length = 256
|
||||||
|
|
||||||
[printer.brother]
|
[printer.brother]
|
||||||
# Configurations for Brother printers
|
# Configurations for Brother printers
|
||||||
label_type = "62" # See https://github.com/pklaus/brother_ql#usage for label types
|
label_type = "62" # See https://github.com/pklaus/brother_ql#usage for label types
|
||||||
|
text_max_length = 4096
|
||||||
|
signature_max_length = 256
|
||||||
|
|
||||||
# Raspberry Pi Configuration
|
# Raspberry Pi Configuration
|
||||||
[rpi]
|
[rpi]
|
||||||
|
|||||||
@@ -16,10 +16,14 @@ waiting_time = 5
|
|||||||
profile = "TM-T20III"
|
profile = "TM-T20III"
|
||||||
label_type = 80 # 80 or 58 ( label width in mm )
|
label_type = 80 # 80 or 58 ( label width in mm )
|
||||||
align_text = "center"
|
align_text = "center"
|
||||||
|
text_max_length = 4096
|
||||||
|
signature_max_length = 256
|
||||||
|
|
||||||
[printer.brother]
|
[printer.brother]
|
||||||
# Configurations for Brother printers
|
# Configurations for Brother printers
|
||||||
label_type = 62 # See https://github.com/pklaus/brother_ql#usage for label types
|
label_type = 62 # See https://github.com/pklaus/brother_ql#usage for label types
|
||||||
|
text_max_length = 4096
|
||||||
|
signature_max_length = 256
|
||||||
|
|
||||||
# Raspberry Pi Configuration
|
# Raspberry Pi Configuration
|
||||||
[rpi]
|
[rpi]
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ def api_print_image():
|
|||||||
|
|
||||||
# TODO: This might not depend on the Raspberry Pi
|
# TODO: This might not depend on the Raspberry Pi
|
||||||
@app.route("/api/camera/picture", methods=["GET"])
|
@app.route("/api/camera/picture", methods=["GET"])
|
||||||
|
@limiter.limit("6/minute", override_defaults=False)
|
||||||
def camera_picture():
|
def camera_picture():
|
||||||
"""Returns a picture taken by the camera on a raspberry pi"""
|
"""Returns a picture taken by the camera on a raspberry pi"""
|
||||||
if RASPBERRY_PI_CONNECTED:
|
if RASPBERRY_PI_CONNECTED:
|
||||||
@@ -378,24 +379,28 @@ def camera_picture():
|
|||||||
|
|
||||||
|
|
||||||
@app.route("/api/queue", methods=["GET"])
|
@app.route("/api/queue", methods=["GET"])
|
||||||
|
@limiter.limit("6/minute", override_defaults=False)
|
||||||
def api_queue_status():
|
def api_queue_status():
|
||||||
"""API endpoint for entire queue"""
|
"""API endpoint for entire queue"""
|
||||||
return jsonify(web.get_queue_state())
|
return jsonify(web.get_queue_state())
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/queue/completed", methods=["GET"])
|
@app.route("/api/queue/completed", methods=["GET"])
|
||||||
|
@limiter.limit("6/minute", override_defaults=False)
|
||||||
def api_queue_completed():
|
def api_queue_completed():
|
||||||
"""API endpoint that returns the finished tasks"""
|
"""API endpoint that returns the finished tasks"""
|
||||||
return jsonify(web.get_queue_completed())
|
return jsonify(web.get_queue_completed())
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/worker", methods=["GET"])
|
@app.route("/api/worker", methods=["GET"])
|
||||||
|
@limiter.limit("6/minute", override_defaults=False)
|
||||||
def api_worker_state():
|
def api_worker_state():
|
||||||
"""API endpoint to get the worker state"""
|
"""API endpoint to get the worker state"""
|
||||||
return jsonify(worker.current_state())
|
return jsonify(worker.current_state())
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/worker/start")
|
@app.route("/api/worker/start")
|
||||||
|
@limiter.limit("6/minute", override_defaults=False)
|
||||||
def api_worker_start():
|
def api_worker_start():
|
||||||
"""
|
"""
|
||||||
Enable to worker. This starts to process the print queue.
|
Enable to worker. This starts to process the print queue.
|
||||||
@@ -405,6 +410,7 @@ def api_worker_start():
|
|||||||
|
|
||||||
|
|
||||||
@app.route("/api/worker/stop")
|
@app.route("/api/worker/stop")
|
||||||
|
@limiter.limit("6/minute", override_defaults=False)
|
||||||
def api_worker_stop():
|
def api_worker_stop():
|
||||||
"""
|
"""
|
||||||
Stops the print queue. This stops the processing of the print queue.
|
Stops the print queue. This stops the processing of the print queue.
|
||||||
@@ -414,6 +420,7 @@ def api_worker_stop():
|
|||||||
|
|
||||||
|
|
||||||
@app.route("/api/printers")
|
@app.route("/api/printers")
|
||||||
|
@limiter.limit("6/minute", override_defaults=False)
|
||||||
def api_printers_info():
|
def api_printers_info():
|
||||||
"""Returns the current state of every printers"""
|
"""Returns the current state of every printers"""
|
||||||
return jsonify(printers_pool.printers_info())
|
return jsonify(printers_pool.printers_info())
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import time
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
import uuid
|
import uuid
|
||||||
import threading
|
import threading
|
||||||
import usb.core
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
import usb.core
|
||||||
from PIL import Image, ImageEnhance, ImageDraw, ImageFont
|
from PIL import Image, ImageEnhance, ImageDraw, ImageFont
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
@@ -119,11 +119,14 @@ class EscPosPrinter(Printer):
|
|||||||
self.usb_args = {}
|
self.usb_args = {}
|
||||||
self.usb_args["idVendor"] = self.vendor_id
|
self.usb_args["idVendor"] = self.vendor_id
|
||||||
self.usb_args["idProduct"] = self.device_id
|
self.usb_args["idProduct"] = self.device_id
|
||||||
|
self.configuration_file = configuration_file
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# This also calls open(), which we need to close()
|
# This also calls open(), which we need to close()
|
||||||
# or else the device will appear as busy.
|
# or else the device will appear as busy.
|
||||||
p = escpos.printer.Usb(self.vendor_id, self.device_id, 0, profile=configuration_file["profile"])
|
p = escpos.printer.Usb(
|
||||||
|
self.vendor_id, self.device_id, 0, profile=configuration_file["profile"]
|
||||||
|
)
|
||||||
except escpos.exceptions.DeviceNotFoundError as e:
|
except escpos.exceptions.DeviceNotFoundError as e:
|
||||||
self.app.logger.error(
|
self.app.logger.error(
|
||||||
"The USB device is not plugged in : %s",
|
"The USB device is not plugged in : %s",
|
||||||
@@ -148,13 +151,13 @@ class EscPosPrinter(Printer):
|
|||||||
vendor_id=self.vendor_id,
|
vendor_id=self.vendor_id,
|
||||||
product_id=self.device_id,
|
product_id=self.device_id,
|
||||||
serial_number="",
|
serial_number="",
|
||||||
label_type=configuration_file["label_type"],
|
label_type=self.configuration_file["label_type"],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Setting up the printing options.
|
# Setting up the printing options.
|
||||||
# TODO : Expose this to the web interface
|
# TODO : Expose this to the web interface
|
||||||
p.set(
|
p.set(
|
||||||
align=configuration_file["align_text"],
|
align=self.configuration_file["align_text"],
|
||||||
font="a",
|
font="a",
|
||||||
bold=False,
|
bold=False,
|
||||||
underline=0,
|
underline=0,
|
||||||
@@ -213,25 +216,25 @@ class EscPosPrinter(Printer):
|
|||||||
clean_signature = str(signature)
|
clean_signature = str(signature)
|
||||||
|
|
||||||
# Make checks on the size of the message being printed
|
# Make checks on the size of the message being printed
|
||||||
# TODO: make the max length configurable
|
if len(clean_msg) > int(self.configuration_file["text_max_length"]):
|
||||||
if len(clean_msg) > 4096:
|
|
||||||
self.app.logger.warning(
|
self.app.logger.warning(
|
||||||
"Could not print message of this length: " + str(len(clean_msg))
|
"Could not print message of this length: " + str(len(clean_msg))
|
||||||
)
|
)
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"Could not print message of this length :"
|
"Could not print message of this length :"
|
||||||
+ str(len(clean_msg))
|
+ str(len(clean_msg))
|
||||||
+ ", needs to be below 4096 caracters long."
|
+ ", needs to be below %s caracters long.",
|
||||||
|
str(self.configuration_file["text_max_length"]),
|
||||||
)
|
)
|
||||||
# TODO: make the max length configurable
|
if len(signature) > int(self.configuration_file["signature_max_length"]):
|
||||||
if len(signature) > 256:
|
|
||||||
self.app.logger.warning(
|
self.app.logger.warning(
|
||||||
"Could not print signature of this length: " + str(len(clean_signature))
|
"Could not print signature of this length: " + str(len(clean_signature))
|
||||||
)
|
)
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"Could not print signature of this length :"
|
"Could not print signature of this length :"
|
||||||
+ str(len(clean_signature))
|
+ str(len(clean_signature))
|
||||||
+ ", needs to be below 256 caracters long."
|
+ ", needs to be below %s caracters long.",
|
||||||
|
str(self.configuration_file["signature_max_length"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Do the actual printing
|
# Do the actual printing
|
||||||
@@ -256,15 +259,15 @@ class EscPosPrinter(Printer):
|
|||||||
def _print_img(self, path, signature="", center=True, process=False):
|
def _print_img(self, path, signature="", center=True, process=False):
|
||||||
clean_signature = str(signature)
|
clean_signature = str(signature)
|
||||||
|
|
||||||
# TODO: make the max length configurable
|
if len(signature) > int(self.configuration_file["signature_max_length"]):
|
||||||
if len(signature) > 256:
|
|
||||||
self.app.logger.warning(
|
self.app.logger.warning(
|
||||||
"Could not print signature of this length: " + str(len(clean_signature))
|
"Could not print signature of this length: " + str(len(clean_signature))
|
||||||
)
|
)
|
||||||
raise ValueError(
|
raise RuntimeError(
|
||||||
"Could not print signature of this length :"
|
"Could not print signature of this length :"
|
||||||
+ str(len(clean_signature))
|
+ str(len(clean_signature))
|
||||||
+ ", needs to be below 256 caracters long."
|
+ ", needs to be below %s caracters long.",
|
||||||
|
str(self.configuration_file["signature_max_length"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
if not os.path.isfile(str(path)):
|
if not os.path.isfile(str(path)):
|
||||||
@@ -311,9 +314,7 @@ class EscPosPrinter(Printer):
|
|||||||
try:
|
try:
|
||||||
self.printer.close()
|
self.printer.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.app.logger.error(
|
self.app.logger.error("Could not close the printer connexion %s", str(e))
|
||||||
"Could not close the printer connexion %s", str(e)
|
|
||||||
)
|
|
||||||
raise RuntimeError("Could not close the printer connexion. ") from e
|
raise RuntimeError("Could not close the printer connexion. ") from e
|
||||||
|
|
||||||
self.app.logger.info("Printed a picture")
|
self.app.logger.info("Printed a picture")
|
||||||
@@ -457,7 +458,9 @@ class BrotherPrinter(Printer):
|
|||||||
vendor_id=vendor_id,
|
vendor_id=vendor_id,
|
||||||
product_id=self.device_id,
|
product_id=self.device_id,
|
||||||
serial_number=serial_number,
|
serial_number=serial_number,
|
||||||
label_type=configuration_file["label_type"], # TODO: Implement automatic label type detection : https://framagit.org/stickoeur/diagnostickoeur/-/blob/no-masters/printit.py?ref_type=heads#L239
|
label_type=configuration_file[
|
||||||
|
"label_type"
|
||||||
|
], # TODO: Implement automatic label type detection : https://framagit.org/stickoeur/diagnostickoeur/-/blob/no-masters/printit.py?ref_type=heads#L239
|
||||||
)
|
)
|
||||||
self.app.logger.debug("Created a Brother printer !")
|
self.app.logger.debug("Created a Brother printer !")
|
||||||
self.ready = True
|
self.ready = True
|
||||||
@@ -473,7 +476,12 @@ class BrotherPrinter(Printer):
|
|||||||
self._print_img(text_to_image(msg))
|
self._print_img(text_to_image(msg))
|
||||||
self._print_img(text_to_image(signature))
|
self._print_img(text_to_image(signature))
|
||||||
|
|
||||||
def _print_img(self, data, signature="", process=False,):
|
def _print_img(
|
||||||
|
self,
|
||||||
|
data,
|
||||||
|
signature="",
|
||||||
|
process=False,
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Print a raster image via a Brother QL printer
|
Print a raster image via a Brother QL printer
|
||||||
"""
|
"""
|
||||||
@@ -513,20 +521,20 @@ class BrotherPrinter(Printer):
|
|||||||
# del be
|
# del be
|
||||||
|
|
||||||
instructions = convert(
|
instructions = convert(
|
||||||
qlr=qlr,
|
qlr=qlr,
|
||||||
images=[im],
|
images=[im],
|
||||||
label=self.printer_info.label_type,
|
label=self.printer_info.label_type,
|
||||||
dither=True,
|
dither=True,
|
||||||
compress=False,
|
compress=False,
|
||||||
dpi_600=False,
|
dpi_600=False,
|
||||||
cut=False,
|
cut=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
success = send(
|
success = send(
|
||||||
instructions=instructions,
|
instructions=instructions,
|
||||||
printer_identifier=BACKEND_STRING_DESCR,
|
printer_identifier=BACKEND_STRING_DESCR,
|
||||||
backend_identifier="pyusb",
|
backend_identifier="pyusb",
|
||||||
blocking=False
|
blocking=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.logger.debug(str(success))
|
self.app.logger.debug(str(success))
|
||||||
@@ -535,7 +543,7 @@ class BrotherPrinter(Printer):
|
|||||||
|
|
||||||
except usb.core.USBError as e:
|
except usb.core.USBError as e:
|
||||||
if "timeout error" in str(e):
|
if "timeout error" in str(e):
|
||||||
self.app.logger.error("USB Timeout Error %s", str(e) )
|
self.app.logger.error("USB Timeout Error %s", str(e))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
# finally:
|
# finally:
|
||||||
@@ -561,27 +569,25 @@ class BrotherPrinter(Printer):
|
|||||||
# be.dispose()
|
# be.dispose()
|
||||||
# del be
|
# del be
|
||||||
instructions = convert(
|
instructions = convert(
|
||||||
qlr=qlr,
|
qlr=qlr,
|
||||||
images=[signature_file],
|
images=[signature_file],
|
||||||
label=self.printer_info.label_type,
|
label=self.printer_info.label_type,
|
||||||
dither=True,
|
dither=True,
|
||||||
compress=False,
|
compress=False,
|
||||||
dpi_600=False,
|
dpi_600=False,
|
||||||
cut=False,
|
cut=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
success = send(
|
success = send(
|
||||||
instructions=instructions,
|
instructions=instructions,
|
||||||
printer_identifier=BACKEND_STRING_DESCR,
|
printer_identifier=BACKEND_STRING_DESCR,
|
||||||
backend_identifier="pyusb",
|
backend_identifier="pyusb",
|
||||||
blocking=False
|
blocking=False,
|
||||||
)
|
)
|
||||||
self.app.logger.debug(str(success))
|
self.app.logger.debug(str(success))
|
||||||
self.app.logger.debug("Printed signature")
|
self.app.logger.debug("Printed signature")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
finally:
|
finally:
|
||||||
@@ -620,7 +626,6 @@ class BrotherPrinter(Printer):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
def _qr(self):
|
def _qr(self):
|
||||||
# This should not be reached by a print on a BrotherQL
|
# This should not be reached by a print on a BrotherQL
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|||||||
@@ -91,25 +91,35 @@ class Printers:
|
|||||||
)
|
)
|
||||||
|
|
||||||
match (manufacturer):
|
match (manufacturer):
|
||||||
case ("EPSON"):
|
case "EPSON":
|
||||||
try:
|
try:
|
||||||
# We create a new EscPosPrinter()
|
# We create a new EscPosPrinter()
|
||||||
self.app.logger.debug("Trying to create a new EPSON printer")
|
self.app.logger.debug("Trying to create a new EPSON printer")
|
||||||
prid = dev.idProduct
|
prid = dev.idProduct
|
||||||
vendir = dev.idVendor
|
vendir = dev.idVendor
|
||||||
escpos_printer = EscPosPrinter(self.app, vendir, prid, self.configuration_file["printer"]["epson"] )
|
escpos_printer = EscPosPrinter(
|
||||||
|
self.app,
|
||||||
|
vendir,
|
||||||
|
prid,
|
||||||
|
self.configuration_file["printer"]["epson"],
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
# If the object creation is successfull, we add it to the list of Printers
|
# If the object creation is successfull, we add it to the list of Printers
|
||||||
printers.add(escpos_printer)
|
printers.add(escpos_printer)
|
||||||
self.app.logger.debug("Found a %s printer", manufacturer)
|
self.app.logger.debug("Found a %s printer", manufacturer)
|
||||||
case ("Brother"):
|
case "Brother":
|
||||||
try:
|
try:
|
||||||
# We create a new BrotherPrinter()
|
# We create a new BrotherPrinter()
|
||||||
self.app.logger.debug("Trying to create a new BROTHER printer")
|
self.app.logger.debug("Trying to create a new BROTHER printer")
|
||||||
|
|
||||||
brother_printer = BrotherPrinter(self.app, dev.idVendor, dev.idProduct, self.configuration_file["printer"]["brother"] )
|
brother_printer = BrotherPrinter(
|
||||||
|
self.app,
|
||||||
|
dev.idVendor,
|
||||||
|
dev.idProduct,
|
||||||
|
self.configuration_file["printer"]["brother"],
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.app.logger.error(
|
self.app.logger.error(
|
||||||
"Could not create a %s printer class with %s:%s",
|
"Could not create a %s printer class with %s:%s",
|
||||||
@@ -122,8 +132,10 @@ class Printers:
|
|||||||
# If the object creation is successfull, we add it to the list of Printers
|
# If the object creation is successfull, we add it to the list of Printers
|
||||||
printers.add(brother_printer)
|
printers.add(brother_printer)
|
||||||
self.app.logger.debug("Found a %s printer", manufacturer)
|
self.app.logger.debug("Found a %s printer", manufacturer)
|
||||||
case (_):
|
case _:
|
||||||
self.app.logger.debug("Found a printer of unknown manufacturer : %s", manufacturer)
|
self.app.logger.debug(
|
||||||
|
"Found a printer of unknown manufacturer : %s", manufacturer
|
||||||
|
)
|
||||||
# end match
|
# end match
|
||||||
|
|
||||||
self.app.logger.debug("Found %s printers", len(printers))
|
self.app.logger.debug("Found %s printers", len(printers))
|
||||||
@@ -156,11 +168,20 @@ class Printers:
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# def printers_info(self):
|
def printers_info(self):
|
||||||
# """Return the current list of printers"""
|
"""Return the current list of printers"""
|
||||||
# printers_info_list = {}
|
printers_info_list = []
|
||||||
# for i in self.printers
|
for i in self.printers:
|
||||||
# return self.printers
|
printers_info_list.append(
|
||||||
|
[
|
||||||
|
i.printer_type.name,
|
||||||
|
"Used: " + str(i.used),
|
||||||
|
"Ready: " + str(i.ready),
|
||||||
|
i.printer_info,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
return printers_info_list
|
||||||
|
|
||||||
|
|
||||||
class _FindClass:
|
class _FindClass:
|
||||||
|
|||||||
@@ -5,6 +5,6 @@
|
|||||||
<title>LittlePrynter API</title>
|
<title>LittlePrynter API</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
"Welcome to the printing software's API. Please see the index page to get started.
|
Welcome to the printing software's API. Please see the index page to get started.
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<footer class="row">
|
<footer class="row">
|
||||||
<p class=" text-center">Little Prynter is built by <a href="https://n07070.xyz/about-me/">n07070</a> because it's fun :) | <a href="https://git.n07070.xyz/n07070/littleprynter">Source code - AGPLv3</a></p>
|
<p class=" text-center">Little Prynter is built by <a href="https://n07070.xyz/about-me/">n07070</a> because it's fun :) | <a href="/api">API interface</a> | <a href="https://git.n07070.xyz/n07070/littleprynter">Source code - AGPLv3</a></p>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
<script src="https://cdn.socket.io/4.0.0/socket.io.min.js"></script>
|
<script src="https://cdn.socket.io/4.0.0/socket.io.min.js"></script>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
<hr>
|
|
||||||
<footer>Little Prynter is built by <a href="https://n07070.xyz/about-me/">n07070</a> because it's fun :) | <a href="https://git.n07070.xyz/n07070/littleprynter/src/branch/epson-tm-t20iii">Source code - AGPLv3</a></footer>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -41,7 +41,9 @@ class Web:
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def print_image(self, image, sign: str, do_cut: bool, process_image: bool, many: int = 1) -> 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.
|
Get an image and a signature, prints the image and cuts after that.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ class PrintWorker(threading.Thread):
|
|||||||
self.app.logger.debug("Ho great, I'm alive... I'm ready to work another day...")
|
self.app.logger.debug("Ho great, I'm alive... I'm ready to work another day...")
|
||||||
|
|
||||||
def _acquire_available_printer(self):
|
def _acquire_available_printer(self):
|
||||||
result = self.printers.acquire_available_printer(start_index=self._printer_index)
|
result = self.printers.acquire_available_printer(
|
||||||
|
start_index=self._printer_index
|
||||||
|
)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -81,17 +83,14 @@ class PrintWorker(threading.Thread):
|
|||||||
)
|
)
|
||||||
self.printer = self._acquire_available_printer()
|
self.printer = self._acquire_available_printer()
|
||||||
self.app.logger.debug(
|
self.app.logger.debug(
|
||||||
|
"The worker got a %s printer and it's %s",
|
||||||
"The worker got a %s printer and it's %s",
|
self.printer.printer_type,
|
||||||
self.printer.printer_type,
|
"Ready" if self.printer.ready else "Not ready",
|
||||||
"Ready" if self.printer.ready else "Not ready",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.printer is None:
|
if self.printer is None:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.printer.use_printer()
|
self.printer.use_printer()
|
||||||
|
|
||||||
# If the printer is not ready, we wait for it to become ready.
|
# If the printer is not ready, we wait for it to become ready.
|
||||||
|
|||||||
Reference in New Issue
Block a user