Added ability to print from a generic file
This commit is contained in:
parent
64e5ea5151
commit
c6ee2f6338
|
@ -128,9 +128,40 @@ class Network(Escpos):
|
||||||
|
|
||||||
|
|
||||||
def _raw(self, msg):
|
def _raw(self, msg):
|
||||||
|
""" Print any command sent in raw format """
|
||||||
self.device.send(msg)
|
self.device.send(msg)
|
||||||
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
""" Close TCP connection """
|
""" Close TCP connection """
|
||||||
self.device.close()
|
self.device.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class File(Escpos):
|
||||||
|
""" Define Generic file printer """
|
||||||
|
|
||||||
|
def __init__(self, devfile="/dev/usb/lp0"):
|
||||||
|
"""
|
||||||
|
@param devfile : Device file under dev filesystem
|
||||||
|
"""
|
||||||
|
self.devfile = devfile
|
||||||
|
self.open()
|
||||||
|
|
||||||
|
|
||||||
|
def open(self):
|
||||||
|
""" Open system file """
|
||||||
|
self.device = open(self.devfile, "wb")
|
||||||
|
|
||||||
|
if self.device is None:
|
||||||
|
print "Could not open the specified file %s" % self.devfile
|
||||||
|
|
||||||
|
|
||||||
|
def _raw(self, msg):
|
||||||
|
""" Print any command sent in raw format """
|
||||||
|
self.device.write(msg);
|
||||||
|
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
""" Close system file """
|
||||||
|
self.device.close()
|
||||||
|
|
Loading…
Reference in New Issue