|
|
|
@ -247,29 +247,28 @@ class Bureau(object):
|
|
|
|
|
subprocess.call("lpr " + pdfpath, shell=True)
|
|
|
|
|
|
|
|
|
|
# TODO: make this asynchronous
|
|
|
|
|
def print_small(self, text, printer="/dev/usb/lp0"):
|
|
|
|
|
def print_small(self, text, cut=True):
|
|
|
|
|
"""
|
|
|
|
|
print on Thermal Line printer.
|
|
|
|
|
"""
|
|
|
|
|
# TODO: look up device and width in config
|
|
|
|
|
# TODO: refactor this to use escpos library
|
|
|
|
|
lp = open(printer, "w")
|
|
|
|
|
text = textwrap.fill(text, width=32)
|
|
|
|
|
text += "\r\n" * 5
|
|
|
|
|
# text += ".d0"
|
|
|
|
|
lp.write(text)
|
|
|
|
|
lp.close()
|
|
|
|
|
prn = printer.Usb(0x416, 05011, in_ep=0x81, out_ep=0x03)
|
|
|
|
|
text = textwrap.fill(text, width=48)
|
|
|
|
|
text += "\r\n" * 2
|
|
|
|
|
prn.text(text + "\r\n\r\n")
|
|
|
|
|
if cut:
|
|
|
|
|
prn.cut()
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
prn = printer.Usb(0x416, 0x5011, in_ep=0x81, out_ep=0x03)
|
|
|
|
|
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
|
|
|
|
|
im.thumbnail((576, 576), PIL.Image.ANTIALIAS) # resize to fit printer
|
|
|
|
|
prn.image(im, impl="bitImageColumn") # not using this impl crashes ??
|
|
|
|
|
|
|
|
|
|
@add_command("test")
|
|
|
|
|