add function close_printer
This commit is contained in:
parent
7ef2acb08e
commit
fe32199a9b
|
@ -200,6 +200,11 @@ class Receipt(object):
|
|||
status = True
|
||||
return status
|
||||
|
||||
def close_printer(self):
|
||||
# only close printer in interfaces correct
|
||||
if self._interface == 'usb' and '/dev/usb/' not in self._device:
|
||||
self._printer.close()
|
||||
|
||||
def set_printer(self):
|
||||
try:
|
||||
status = self.check_status(self._interface, self._device)
|
||||
|
@ -316,7 +321,7 @@ class Receipt(object):
|
|||
self._printer.ln(3)
|
||||
self._printer.cut()
|
||||
self._printer.ln(2)
|
||||
self._printer.close()
|
||||
# self._printer.close()
|
||||
|
||||
def print_line(self, *args):
|
||||
text = ''
|
||||
|
@ -473,7 +478,7 @@ class Receipt(object):
|
|||
self._printer.textln('NOTA:' + ln.get('note'))
|
||||
self._printer.ln(2)
|
||||
self._printer.cut()
|
||||
self._printer.close()
|
||||
self.close_printer()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
traceback.print_exc()
|
||||
|
|
|
@ -9,8 +9,8 @@ from app.reporting import Receipt
|
|||
fake_data = {
|
||||
"12": {
|
||||
"printer": {
|
||||
"device": "172.16.10.31",
|
||||
"interface": "network",
|
||||
"device": "/dev/usb/lp1",
|
||||
"interface": "usb",
|
||||
"profile": "",
|
||||
"row_characters": None
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue