|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
# bureau
|
|
|
|
|
import configparser
|
|
|
|
|
import fcntl
|
|
|
|
|
import functools
|
|
|
|
|
import glob
|
|
|
|
|
import inspect
|
|
|
|
@ -87,6 +88,8 @@ class LogPrinter(logging.Handler):
|
|
|
|
|
logging.Handler.__init__(self)
|
|
|
|
|
|
|
|
|
|
def emit(self, record):
|
|
|
|
|
sm_print_lockfile = open("small_printer_lock", "w")
|
|
|
|
|
fcntl.lockf(sm_print_lockfile, fcntl.LOCK_EX)
|
|
|
|
|
if (self.printer["inep"] is None) and (self.printer["outep"] is None):
|
|
|
|
|
prn = printer.Usb(self.printer["vendorid"], self.printer["productid"])
|
|
|
|
|
else:
|
|
|
|
@ -106,6 +109,8 @@ class LogPrinter(logging.Handler):
|
|
|
|
|
prn.text(out_text)
|
|
|
|
|
prn.cut()
|
|
|
|
|
prn.close()
|
|
|
|
|
fcntl.lockf(sm_print_lockfile, fcntl.LOCK_EX)
|
|
|
|
|
sm_print_lockfile.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class KeyValStore(object):
|
|
|
|
@ -418,6 +423,8 @@ class Bureau(object):
|
|
|
|
|
"""
|
|
|
|
|
returns an instance of the small escpos printer
|
|
|
|
|
"""
|
|
|
|
|
self._sm_print_lockfile = open("small_printer_lock", "w")
|
|
|
|
|
fcntl.lockf(self._sm_print_lockfile, fcntl.LOCK_EX)
|
|
|
|
|
if (self.smprint["inep"] is None) and (self.smprint["outep"] is None):
|
|
|
|
|
prn = printer.Usb(self.smprint["vendorid"],
|
|
|
|
|
self.smprint["productid"])
|
|
|
|
@ -429,6 +436,14 @@ class Bureau(object):
|
|
|
|
|
prn.profile = self.smprint["profile"]
|
|
|
|
|
return prn
|
|
|
|
|
|
|
|
|
|
def _free_small_printer(self, printer):
|
|
|
|
|
"""
|
|
|
|
|
cleans up and unlocks the small printer
|
|
|
|
|
"""
|
|
|
|
|
printer.close()
|
|
|
|
|
fcntl.lockf(self._sm_print_lockfile, fcntl.LOCK_UN)
|
|
|
|
|
self._sm_print_lockfile.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def print_full(self, template, **kwargs):
|
|
|
|
|
"""print a full page (A4) document """
|
|
|
|
@ -485,7 +500,7 @@ class Bureau(object):
|
|
|
|
|
prn.ln(2)
|
|
|
|
|
if cut:
|
|
|
|
|
prn.cut()
|
|
|
|
|
prn.close()
|
|
|
|
|
self._free_small_printer(prn)
|
|
|
|
|
|
|
|
|
|
def print_small_image(self, img, linefeed=True):
|
|
|
|
|
"""
|
|
|
|
@ -507,6 +522,7 @@ class Bureau(object):
|
|
|
|
|
prn.image(im, impl="bitImageColumn")
|
|
|
|
|
if linefeed:
|
|
|
|
|
prn.ln()
|
|
|
|
|
self._free_small_printer(prn)
|
|
|
|
|
|
|
|
|
|
@add_command("test")
|
|
|
|
|
def test(self, data=None):
|
|
|
|
|