diff --git a/zpl/__pycache__/__init__.cpython-310.pyc b/zpl/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..5b7a38a Binary files /dev/null and b/zpl/__pycache__/__init__.cpython-310.pyc differ diff --git a/zpl/__pycache__/label.cpython-310.pyc b/zpl/__pycache__/label.cpython-310.pyc new file mode 100644 index 0000000..2eadafe Binary files /dev/null and b/zpl/__pycache__/label.cpython-310.pyc differ diff --git a/zpl/__pycache__/printer.cpython-310.pyc b/zpl/__pycache__/printer.cpython-310.pyc new file mode 100644 index 0000000..c2a0ad8 Binary files /dev/null and b/zpl/__pycache__/printer.cpython-310.pyc differ diff --git a/zpl/printer.py b/zpl/printer.py index 7600213..8b941c7 100755 --- a/zpl/printer.py +++ b/zpl/printer.py @@ -240,8 +240,8 @@ def send_job(self, zpl2): except socket.timeout: log.error('Send timeout') raise - except: - log.exception() + except Exception as error: + log.exception(error) raise finally: log.debug('Send finished') @@ -261,8 +261,8 @@ def request_info(self, command): except socket.timeout: log.error('Send timeout') raise - except: - log.exception() + except Exception as error: + log.exception(error) raise finally: log.debug('Request finished') @@ -275,11 +275,17 @@ def __del__(self): class FilePrinter(Printer): def __init__(self, filename, mode='w', dpmm=12, ): assert mode in 'wa', "only write 'w' or append 'a' is supported as mode" - self.file = open(filename, mode) + self.file_name = filename + self.file_mode = mode self.dpmm = dpmm def send_job(self, zpl2): - self.file.write(zpl2) + self.file = open(self.file_name, self.file_mode) + if isinstance(zpl2, zpl.label.Label): + self.file.write(zpl2.dumpZPL()) + else: + self.file.write(zpl2) + self.file.close() def send_request(self, command): raise NotImplementedError