Restructure the code and implement a printing queue #29

Merged
n07070 merged 21 commits from restructure-printing-queue into master 2026-05-27 00:00:56 +02:00
Showing only changes of commit 8134c5e892 - Show all commits

View File

@@ -1,4 +1,6 @@
"""
This class manages connexion to a Printer
"""
# import brother_ql
from time import sleep
import os.path
@@ -10,7 +12,7 @@ import numpy as np
import escpos.printer
class Printer(object):
class Printer():
"""
# The connection is based on the ESC/POS library
@@ -31,7 +33,7 @@ class Printer(object):
ready = False
def __init__(self, app, device_id, vendor_id):
super(Printer, self).__init__()
super().__init__()
self.app = app
self.ready = False
self.printer = None
@@ -99,7 +101,6 @@ class Printer(object):
waiting_elapsed,
str(e),
)
pass
sleep(1)
waiting_elapsed -= 1
@@ -207,8 +208,8 @@ class Printer(object):
+ str(path)
+ " wasn't found. Please try again."
)
else:
self.app.logger.debug("Printing file from " + str(path))
self.app.logger.debug("Printing file from " + str(path))
if process:
try:
@@ -309,7 +310,8 @@ def _process_image(self, path):
self.app.logger.debug("Resized the image")
# # Convert to grayscale for dithering
# dithered_img = original_img.convert("L").convert("1") # Dithering using default method (FloydSteinberg)
# dithered_img = original_img.convert("L").convert("1")
# Dithering using default method (FloydSteinberg)
# self.app.logger.debug("Dithered the image")
# Compute brightness of original image (grayscale average)