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:
Patrick Kanzler 2017-01-30 16:12:37 +01:00
parent 1038844567
commit e92f00cdf3
No known key found for this signature in database
GPG Key ID: F07F07153306FCEF
1 changed files with 6 additions and 4 deletions

View File

@ -211,6 +211,7 @@ class Network(Escpos):
def close(self):
""" Close TCP connection """
if self.device is not None:
self.device.shutdown(socket.SHUT_RDWR)
self.device.close()
@ -263,6 +264,7 @@ class File(Escpos):
def close(self):
""" Close system file """
if self.device is not None:
self.device.flush()
self.device.close()