fix AttributeError when executing close
When self.device is already None an AttributeError will occur. This is relevant to #189.
This commit is contained in:
parent
1038844567
commit
e92f00cdf3
|
@ -211,8 +211,9 @@ class Network(Escpos):
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
""" Close TCP connection """
|
""" Close TCP connection """
|
||||||
self.device.shutdown(socket.SHUT_RDWR)
|
if self.device is not None:
|
||||||
self.device.close()
|
self.device.shutdown(socket.SHUT_RDWR)
|
||||||
|
self.device.close()
|
||||||
|
|
||||||
|
|
||||||
class File(Escpos):
|
class File(Escpos):
|
||||||
|
@ -263,8 +264,9 @@ class File(Escpos):
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
""" Close system file """
|
""" Close system file """
|
||||||
self.device.flush()
|
if self.device is not None:
|
||||||
self.device.close()
|
self.device.flush()
|
||||||
|
self.device.close()
|
||||||
|
|
||||||
|
|
||||||
class Dummy(Escpos):
|
class Dummy(Escpos):
|
||||||
|
|
Loading…
Reference in New Issue