1 from django.conf import settings
8 def print_zpl(zpl_text, host=None):
10 Sends zpl_text to printer
13 host = settings.BCPRINTER_PRINTER1_HOST
14 ftp = ftplib.FTP(host=host, user='blank', passwd='')
16 ftp.storlines("STOR printme.txt", StringIO.StringIO(zpl_text))
20 def print_zpl_socket(zpl_text, host=None, port=None):
22 Sends zpl_text to printer via a socket
24 if zpl_text is a list of zpl_texts, it will print each one
29 host=settings.BCPRINTER_PRINTER1_HOST
31 port=settings.BCPRINTER_PRINTER1_PORT
33 # Process anyway if zpl_text is a list.
34 if type(zpl_text) is list:
35 zpl_text = '\n'.join(zpl_text)
38 # PORT 9100 is default for Zebra tabletop/desktop printers
39 # PORT 6101 is default for Zebra mobile printers
40 s.connect((host, port))
45 def report_error(message):
47 Return a dictionary with a command to display 'message'
49 return {'mode': 'Error', 'status': message}
52 def redirect_to_url(url):
54 Return a bcm dictionary with a command to redirect to 'url'
56 return {'mode': 'redirect', 'url': url}
59 def autofill(field, value):
61 Return a bcm dictionary with a command to automatically fill the
62 corresponding "field" with "value"
64 return {'mode': 'autofill', 'field': field, 'value': value}