Restore device status to False on close()

This commit is contained in:
belono 2023-09-03 20:12:11 +02:00
parent 21b329a955
commit 7103af083c
7 changed files with 7 additions and 7 deletions

View File

@ -181,4 +181,4 @@ class CupsPrinter(Escpos):
if self.pending_job: if self.pending_job:
self.send() self.send()
print(f"Closing CUPS connection to printer {self.printer_name}") print(f"Closing CUPS connection to printer {self.printer_name}")
self.device = None self._device = False

View File

@ -76,4 +76,4 @@ class File(Escpos):
return return
self.device.flush() self.device.flush()
self.device.close() self.device.close()
self.device = None self._device = False

View File

@ -87,7 +87,7 @@ class LP(Escpos):
if not self._device: if not self._device:
return return
self.device.terminate() self.device.terminate()
self.device = None self._device = False
def flush(self): def flush(self):
"""End line and wait for new commands.""" """End line and wait for new commands."""

View File

@ -92,4 +92,4 @@ class Network(Escpos):
except socket.error: except socket.error:
pass pass
self.device.close() self.device.close()
self.device = None self._device = False

View File

@ -151,4 +151,4 @@ class Serial(Escpos):
if self.device.is_open: if self.device.is_open:
self.device.flush() self.device.flush()
self.device.close() self.device.close()
self.device = None self._device = False

View File

@ -156,4 +156,4 @@ class Usb(Escpos):
if not self._device: if not self._device:
return return
usb.util.dispose_resources(self.device) usb.util.dispose_resources(self.device)
self.device = None self._device = False

View File

@ -97,7 +97,7 @@ class Win32Raw(Escpos):
win32print.EndPagePrinter(self.device) win32print.EndPagePrinter(self.device)
win32print.EndDocPrinter(self.device) win32print.EndDocPrinter(self.device)
win32print.ClosePrinter(self.device) win32print.ClosePrinter(self.device)
self.device = None self._device = False
@dependency_win32print @dependency_win32print
def _raw(self, msg): def _raw(self, msg):