Restructure the code and implement a printing queue #29
@@ -1,4 +1,6 @@
|
|||||||
|
"""
|
||||||
|
This class manages connexion to a Printer
|
||||||
|
"""
|
||||||
# import brother_ql
|
# import brother_ql
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import os.path
|
import os.path
|
||||||
@@ -10,7 +12,7 @@ import numpy as np
|
|||||||
import escpos.printer
|
import escpos.printer
|
||||||
|
|
||||||
|
|
||||||
class Printer(object):
|
class Printer():
|
||||||
"""
|
"""
|
||||||
# The connection is based on the ESC/POS library
|
# The connection is based on the ESC/POS library
|
||||||
|
|
||||||
@@ -31,7 +33,7 @@ class Printer(object):
|
|||||||
ready = False
|
ready = False
|
||||||
|
|
||||||
def __init__(self, app, device_id, vendor_id):
|
def __init__(self, app, device_id, vendor_id):
|
||||||
super(Printer, self).__init__()
|
super().__init__()
|
||||||
self.app = app
|
self.app = app
|
||||||
self.ready = False
|
self.ready = False
|
||||||
self.printer = None
|
self.printer = None
|
||||||
@@ -99,7 +101,6 @@ class Printer(object):
|
|||||||
waiting_elapsed,
|
waiting_elapsed,
|
||||||
str(e),
|
str(e),
|
||||||
)
|
)
|
||||||
pass
|
|
||||||
|
|
||||||
sleep(1)
|
sleep(1)
|
||||||
waiting_elapsed -= 1
|
waiting_elapsed -= 1
|
||||||
@@ -207,8 +208,8 @@ class Printer(object):
|
|||||||
+ str(path)
|
+ str(path)
|
||||||
+ " wasn't found. Please try again."
|
+ " 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:
|
if process:
|
||||||
try:
|
try:
|
||||||
@@ -309,7 +310,8 @@ def _process_image(self, path):
|
|||||||
self.app.logger.debug("Resized the image")
|
self.app.logger.debug("Resized the image")
|
||||||
|
|
||||||
# # Convert to grayscale for dithering
|
# # Convert to grayscale for dithering
|
||||||
# dithered_img = original_img.convert("L").convert("1") # Dithering using default method (Floyd–Steinberg)
|
# dithered_img = original_img.convert("L").convert("1")
|
||||||
|
# Dithering using default method (Floyd–Steinberg)
|
||||||
# self.app.logger.debug("Dithered the image")
|
# self.app.logger.debug("Dithered the image")
|
||||||
|
|
||||||
# Compute brightness of original image (grayscale average)
|
# Compute brightness of original image (grayscale average)
|
||||||
|
|||||||
Reference in New Issue
Block a user