Mercurial > hg > zebra
comparison zebra.py @ 26:20f6df6d3f42
- Fix for empty printer list
- Updated to 0.0.4a
- Altered to use pip
author | Ben Croston <ben@croston.org> |
---|---|
date | Sat, 16 Nov 2013 17:17:15 +0000 |
parents | fc1a7cf3f92c |
children | 7c132e01c281 |
comparison
equal
deleted
inserted
replaced
25:fc1a7cf3f92c | 26:20f6df6d3f42 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2011 Ben Croston | 3 # Copyright (c) 2011-2013 Ben Croston |
4 # | 4 # |
5 # Permission is hereby granted, free of charge, to any person obtaining a copy of | 5 # Permission is hereby granted, free of charge, to any person obtaining a copy of |
6 # this software and associated documentation files (the "Software"), to deal in | 6 # this software and associated documentation files (the "Software"), to deal in |
7 # the Software without restriction, including without limitation the rights to | 7 # the Software without restriction, including without limitation the rights to |
8 # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | 8 # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
58 win32print.EndPagePrinter(hPrinter) | 58 win32print.EndPagePrinter(hPrinter) |
59 finally: | 59 finally: |
60 win32print.EndDocPrinter(hPrinter) | 60 win32print.EndDocPrinter(hPrinter) |
61 finally: | 61 finally: |
62 win32print.ClosePrinter(hPrinter) | 62 win32print.ClosePrinter(hPrinter) |
63 | 63 |
64 def output(self, commands): | 64 def output(self, commands): |
65 """Output EPL2 commands to the label printer | 65 """Output EPL2 commands to the label printer |
66 | 66 |
67 commands - EPL2 commands to send to the printer | 67 commands - EPL2 commands to send to the printer |
68 """ | 68 """ |
77 else: | 77 else: |
78 self._output_unix(commands) | 78 self._output_unix(commands) |
79 | 79 |
80 def _getqueues_unix(self): | 80 def _getqueues_unix(self): |
81 queues = [] | 81 queues = [] |
82 output = subprocess.check_output(['lpstat','-p'], universal_newlines=True) | 82 try: |
83 output = subprocess.check_output(['lpstat','-p'], universal_newlines=True) | |
84 except subprocess.CalledProcessError: | |
85 return [] | |
83 for line in output.split('\n'): | 86 for line in output.split('\n'): |
84 if line.startswith('printer'): | 87 if line.startswith('printer'): |
85 queues.append(line.split(' ')[1]) | 88 queues.append(line.split(' ')[1]) |
86 return queues | 89 return queues |
87 | 90 |