Fix LP waste of paper due to auto-flush + flush on close
This commit is contained in:
parent
0984c93975
commit
86ae775881
@ -99,6 +99,7 @@ class File(Escpos):
|
|||||||
if not self._device:
|
if not self._device:
|
||||||
return
|
return
|
||||||
logging.info("Closing File connection to printer %s", self.devfile)
|
logging.info("Closing File connection to printer %s", self.devfile)
|
||||||
self.device.flush()
|
if not self.auto_flush:
|
||||||
|
self.flush()
|
||||||
self.device.close()
|
self.device.close()
|
||||||
self._device = False
|
self._device = False
|
||||||
|
@ -67,11 +67,11 @@ class LP(Escpos):
|
|||||||
|
|
||||||
:param printer_name: CUPS printer name (Optional)
|
:param printer_name: CUPS printer name (Optional)
|
||||||
:param auto_flush: Automatic flush after every _raw() (Optional)
|
:param auto_flush: Automatic flush after every _raw() (Optional)
|
||||||
:type auto_flush: bool
|
:type auto_flush: bool (Defaults False)
|
||||||
"""
|
"""
|
||||||
Escpos.__init__(self, *args, **kwargs)
|
Escpos.__init__(self, *args, **kwargs)
|
||||||
self.printer_name = printer_name
|
self.printer_name = printer_name
|
||||||
self.auto_flush = kwargs.get("auto_flush", True)
|
self.auto_flush = kwargs.get("auto_flush", False)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def printers(self) -> dict:
|
def printers(self) -> dict:
|
||||||
@ -150,6 +150,8 @@ class LP(Escpos):
|
|||||||
if not self._device:
|
if not self._device:
|
||||||
return
|
return
|
||||||
logging.info("Closing LP connection to printer %s", self.printer_name)
|
logging.info("Closing LP connection to printer %s", self.printer_name)
|
||||||
|
if not self.auto_flush:
|
||||||
|
self.flush()
|
||||||
self.device.terminate()
|
self.device.terminate()
|
||||||
self._device = False
|
self._device = False
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user