Mercurial > hg > zebra
changeset 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 | 3cad40fda053 |
children | 777602a0da24 |
files | README setup.py zebra.py |
diffstat | 3 files changed, 14 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/README Mon Aug 15 19:25:52 2011 +0100 +++ b/README Mon Aug 15 20:18:38 2011 +0100 @@ -1,5 +1,5 @@ ============ -Zebra-0.0.2a +Zebra-0.0.3a ============ Note: @@ -13,27 +13,25 @@ from zebra import zebra z = zebra( [queue] ) - - Constructor with optional printer queue + Constructor with optional printer queue z.getqueues() - - Return a list containing available printer queues + Return a list containing available printer queues z.setqueue( queue ) - - Set the printer queue + Set the printer queue z.setup( direct_thermal=None, label_height=None, label_width=None ) Set up the label printer. Parameters are not set if they are None. - direct_thermal - True if using direct thermal labels label_height - tuple (label height, label gap) in dots label_width - in dots z.store_graphic( name, filename ) - Store a .PCX file on the label printer - + Store a .PCX file on the label printer name - name to be used on printer filename - local filename z.output( commands ) - - Output EPL2 commands to the printer + Output EPL2 commands to the printer
--- a/setup.py Mon Aug 15 19:25:52 2011 +0100 +++ b/setup.py Mon Aug 15 20:18:38 2011 +0100 @@ -11,8 +11,6 @@ 'Operating System :: Microsoft :: Windows', 'Operating System :: Unix', 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Topic :: Printing'] @@ -24,12 +22,12 @@ try: import win32print except: - raise Exception('Requires the win32print module from the pywin32 package') + raise Exception('Requires the win32print module from the pywin32 package.\nDownload from http://pypi.python.org/pypi/pywin32/') else: requires = [] setup(name = 'zebra', - version = '0.0.2a', + version = '0.0.3a', py_modules = ['zebra'], author = 'Ben Croston', author_email = 'ben@croston.org',
--- 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: