Mercurial > hg > zebra
diff zebra.py @ 17:a9dacd180597
Does not work in python 2.6 after all
Tidy up
author | Ben Croston <ben@croston.org> |
---|---|
date | Mon, 15 Aug 2011 20:18:38 +0100 |
parents | e6ea86e3d0e1 |
children | 117c2aac83e5 |
line wrap: on
line diff
--- a/zebra.py Mon Aug 15 19:25:52 2011 +0100 +++ b/zebra.py Mon Aug 15 20:18:38 2011 +0100 @@ -22,18 +22,13 @@ p = subprocess.Popen(['cat','-'], stdin=subprocess.PIPE) else: p = subprocess.Popen(['lpr','-P%s'%self.queue], stdin=subprocess.PIPE) - if type(commands) == bytes: - p.communicate(commands) - else: - p.communicate(str(commands).encode()) + p.communicate(commands) p.stdin.close() def _output_win(self, commands): if self.queue == 'zebra_python_unittest': print commands return - if type(commands) != bytes: - commands = str(commands).encode() hPrinter = win32print.OpenPrinter(self.queue) try: hJob = win32print.StartDocPrinter(hPrinter, 1, ('Label',None,'RAW')) @@ -52,6 +47,11 @@ commands - EPL2 commands to send to the printer """ assert self.queue is not None + if sys.version_info[0] == 3: + if type(commands) != bytes: + commands = str(commands).encode() + else: + commands = str(commands).encode() if IS_WINDOWS: self._output_win(commands) else: