Added ability to print from a generic file

This commit is contained in:
Manuel F Martinez 2013-04-12 14:04:48 -07:00
parent 64e5ea5151
commit c6ee2f6338
1 changed files with 31 additions and 0 deletions

View File

@ -128,9 +128,40 @@ class Network(Escpos):
def _raw(self, msg):
""" Print any command sent in raw format """
self.device.send(msg)
def __del__(self):
""" Close TCP connection """
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()