add proper config profiles for small printers

workspace
Brendan Howell 4 years ago
parent 0c9c5dcad0
commit ccb71119cc

@ -20,6 +20,7 @@ import PIL
import weasyprint
import zmq
from escpos import printer
from escpos import capabilities as printcaps
from mako.template import Template
from ruamel.yaml import YAML
@ -86,12 +87,14 @@ class LogPrinter(logging.Handler):
def emit(self, record):
if (self.printer["inep"] is None) and (self.printer["outep"] is None):
prn = printer.Usb(self.printer["vendorid"], self.printer["productid"])
prn = printer.Usb(self.printer["vendorid"], self.printer["productid"],
profile=self.printer["profile"])
else:
prn = printer.Usb(self.printer["vendorid"],
self.printer["productid"],
in_ep=self.printer["inep"],
out_ep=self.printer["outep"])
out_ep=self.printer["outep"],
profile=self.printer["profile"])
prn.set()
msg = self.format(record)
#text = textwrap.fill(msg, width=self.printer["textwidth"])
@ -211,8 +214,20 @@ class Bureau(object):
self.smprint[hexkey] = None
else:
self.smprint[hexkey] = int(val, 16)
self.smprint["width"] = int(printcfg["smallprinter"]["width"])
self.smprint["textwidth"] = int(printcfg["smallprinter"]["textwidth"])
profile = printcfg["smallprinter"]["profile"]
if profile.strip() == "":
features = {'barcodeA': False, 'barcodeB': False,
'bitImageColumn': True, 'bitImageRaster': True,
'graphics': False, 'highDensity': False,
'paperFullCut': False, 'paperPartCut': False,
'pdf417Code': False, 'pulseBel': False,
'pulseStandard': True, 'qrCode': False,
'starCommands': False}
self.smprint["profile"] = printcaps.Profile(columns=32,
features=features)
else:
self.smprint["profile"] = printcaps.get_profile(profile)
self.lp = {}
self.lp["name"] = printcfg["largeprinter"]["name"]
@ -221,7 +236,8 @@ class Bureau(object):
except KeyError:
# TODO: eventually refactor this since it could overwrite a half-broken config
sp_dict = {"vendorid": "", "productid": "", "inep": "",
"outep": "", "width": "384", "textwidth": "32"}
"outep": "", "width": "384", "textwidth": "32",
"profile", None}
lp_dict = {"name": "", "papersize": "A4", "duplex": "False"}
printcfg["smallprinter"] = sp_dict
printcfg["largeprinter"] = lp_dict

Loading…
Cancel
Save