Skip to content

Commit

Permalink
Corrected style errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeoLacruz committed Feb 18, 2024
1 parent c0cfc74 commit ca8e664
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
pip install pep8-naming==0.13.3
- name: Check style
with: max-line-length: "100"
run: |
flake8 .
Expand Down
4 changes: 2 additions & 2 deletions inventree_zebra/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# server.py
# simple listener to an IP port to test the zebra plugin with IP conection in case you
# do not have a printer with IP interface.
# simple listener to an IP port to test the zebra plugin with IP conection
# in case you do not have a printer with IP interface.

import socket

Expand Down
31 changes: 16 additions & 15 deletions inventree_zebra/zebra_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from inventree_zebra.version import ZEBRA_PLUGIN_VERSION

class ZebraLabelPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlugin):

class ZebraLabelPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlugin):

AUTHOR = "Michael Buchmann"
DESCRIPTION = "Label printing plugin for Zebra printers"
Expand All @@ -31,7 +31,8 @@ class ZebraLabelPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlugin):
'CONNECTION': {
'name': _('Printer Interface'),
'description': _('Select local or network printer'),
'choices': [('local', 'Local printer e.g. USB'), ('network', 'Network printer with IP address')],
'choices': [('local', 'Local printer e.g. USB'),
('network', 'Network printer with IP address')],
'default': 'local',
},
'IP_ADDRESS': {
Expand Down Expand Up @@ -64,7 +65,7 @@ class ZebraLabelPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlugin):
'DPMM': {
'name': _('Dots per mm'),
'description': _('The resolution of the printer'),
'choices': [(8,'8 dots per mm'),(12,'12 dots per mm'),(24,'24 dots per mm')],
'choices': [(8,'8 dots per mm'), (12, '12 dots per mm'), (24, '24 dots per mm')],
'default': 8,
},
'PRINTER_INIT': {
Expand Down Expand Up @@ -99,33 +100,33 @@ def print_label(self, **kwargs):
# label_image.save('/home/user/label.png')

# Convert image to Zebra zpl
l = zpl.Label(height, width, dpmm)
l.set_darkness(darkness)
l.labelhome(0,0)
l.zpl_raw(printer_init)
l.origin(0,0)
l.write_graphic(label_image, width)
l.endorigin()
li = zpl.Label(height, width, dpmm)
li.set_darkness(darkness)
li.labelhome(0, 0)
li.zpl_raw(printer_init)
li.origin(0, 0)
li.write_graphic(label_image, width)
li.endorigin()

# Uncomment this if you need the intermetiate zpl file for debugging.
# datafile=open('/home/user/label.txt','w')
# datafile.write(l.dumpZPL())
# datafile.write(li.dumpZPL())
# datafile.close()

# Send the label to the printer
if(connection == 'local'):
if (connection == 'local'):
try:
pass
printer=open(interface,'w')
printer.write(l.dumpZPL())
printer = open(interface, 'w')
printer.write(li.dumpZPL())
printer.close()
except Exception as error:
raise ConnectionError('Error connecting to local printer: ' + str(error))
elif(connection=='network'):
try:
mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysocket.connect((ip_address, port))
data = l.dumpZPL()
data = li.dumpZPL()
mysocket.send(data.encode())
mysocket.close()
except Exception as error:
Expand Down

0 comments on commit ca8e664

Please sign in to comment.