|
|
@ -11,7 +11,9 @@ import threading
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
import lmdb
|
|
|
|
import lmdb
|
|
|
|
|
|
|
|
import PIL
|
|
|
|
import zmq
|
|
|
|
import zmq
|
|
|
|
|
|
|
|
from escpos import printer
|
|
|
|
from mako.template import Template
|
|
|
|
from mako.template import Template
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -239,6 +241,7 @@ class Bureau(object):
|
|
|
|
print on Thermal Line printer.
|
|
|
|
print on Thermal Line printer.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
# TODO: look up device and width in config
|
|
|
|
# TODO: look up device and width in config
|
|
|
|
|
|
|
|
# TODO: refactor this to use escpos library
|
|
|
|
lp = open(printer, "w")
|
|
|
|
lp = open(printer, "w")
|
|
|
|
text = textwrap.fill(text, width=32)
|
|
|
|
text = textwrap.fill(text, width=32)
|
|
|
|
text += "\r\n" * 5
|
|
|
|
text += "\r\n" * 5
|
|
|
@ -246,6 +249,18 @@ class Bureau(object):
|
|
|
|
lp.write(text)
|
|
|
|
lp.write(text)
|
|
|
|
lp.close()
|
|
|
|
lp.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def print_small_image(self, img):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
print an image on the mini thermal printer.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
# TODO: make printer id/width configured and easy
|
|
|
|
|
|
|
|
prn = printer.Usb(0x416, 0x5011)
|
|
|
|
|
|
|
|
im = PIL.Image.open(img)
|
|
|
|
|
|
|
|
# NOTE: might be worth tring to push up brightness
|
|
|
|
|
|
|
|
im = PIL.ImageOps.equalize(im) # stretch histogram for nicer dither
|
|
|
|
|
|
|
|
im.thumbnail((384, 384), PIL.Image.ANTIALIAS) # resize to fit printer
|
|
|
|
|
|
|
|
prn.image(im, impl="bitImageColumn") # not using this impl crashes ??
|
|
|
|
|
|
|
|
|
|
|
|
@add_command("test")
|
|
|
|
@add_command("test")
|
|
|
|
def test(self, data=None):
|
|
|
|
def test(self, data=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|