mirror of
				https://github.com/python-escpos/python-escpos
				synced 2025-10-23 09:30:00 +00:00 
			
		
		
		
	Restore device status to False on close()
This commit is contained in:
		@@ -181,4 +181,4 @@ class CupsPrinter(Escpos):
 | 
			
		||||
        if self.pending_job:
 | 
			
		||||
            self.send()
 | 
			
		||||
        print(f"Closing CUPS connection to printer {self.printer_name}")
 | 
			
		||||
        self.device = None
 | 
			
		||||
        self._device = False
 | 
			
		||||
 
 | 
			
		||||
@@ -76,4 +76,4 @@ class File(Escpos):
 | 
			
		||||
            return
 | 
			
		||||
        self.device.flush()
 | 
			
		||||
        self.device.close()
 | 
			
		||||
        self.device = None
 | 
			
		||||
        self._device = False
 | 
			
		||||
 
 | 
			
		||||
@@ -87,7 +87,7 @@ class LP(Escpos):
 | 
			
		||||
        if not self._device:
 | 
			
		||||
            return
 | 
			
		||||
        self.device.terminate()
 | 
			
		||||
        self.device = None
 | 
			
		||||
        self._device = False
 | 
			
		||||
 | 
			
		||||
    def flush(self):
 | 
			
		||||
        """End line and wait for new commands."""
 | 
			
		||||
 
 | 
			
		||||
@@ -92,4 +92,4 @@ class Network(Escpos):
 | 
			
		||||
        except socket.error:
 | 
			
		||||
            pass
 | 
			
		||||
        self.device.close()
 | 
			
		||||
        self.device = None
 | 
			
		||||
        self._device = False
 | 
			
		||||
 
 | 
			
		||||
@@ -151,4 +151,4 @@ class Serial(Escpos):
 | 
			
		||||
        if self.device.is_open:
 | 
			
		||||
            self.device.flush()
 | 
			
		||||
            self.device.close()
 | 
			
		||||
        self.device = None
 | 
			
		||||
        self._device = False
 | 
			
		||||
 
 | 
			
		||||
@@ -156,4 +156,4 @@ class Usb(Escpos):
 | 
			
		||||
        if not self._device:
 | 
			
		||||
            return
 | 
			
		||||
        usb.util.dispose_resources(self.device)
 | 
			
		||||
        self.device = None
 | 
			
		||||
        self._device = False
 | 
			
		||||
 
 | 
			
		||||
@@ -97,7 +97,7 @@ class Win32Raw(Escpos):
 | 
			
		||||
        win32print.EndPagePrinter(self.device)
 | 
			
		||||
        win32print.EndDocPrinter(self.device)
 | 
			
		||||
        win32print.ClosePrinter(self.device)
 | 
			
		||||
        self.device = None
 | 
			
		||||
        self._device = False
 | 
			
		||||
 | 
			
		||||
    @dependency_win32print
 | 
			
		||||
    def _raw(self, msg):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user