X-Git-Url: http://woldlab.caltech.edu/gitweb/?a=blobdiff_plain;f=htsworkflow%2Ffrontend%2Fbcmagic%2Futils.py;h=ee35268dbc85d4156c19f6903130a3427d761aa6;hb=198f594766e60957a043ed792ad56382d3f82247;hp=5ee81a95401c485ebe815af2127ea651bf0378f7;hpb=a665e4fe2ad76df437dedfeb4fed3acb56fa7e1d;p=htsworkflow.git diff --git a/htsworkflow/frontend/bcmagic/utils.py b/htsworkflow/frontend/bcmagic/utils.py index 5ee81a9..ee35268 100644 --- a/htsworkflow/frontend/bcmagic/utils.py +++ b/htsworkflow/frontend/bcmagic/utils.py @@ -1,4 +1,30 @@ +from htsworkflow.frontend import settings +import ftplib +import socket +import StringIO + + +def print_zpl(zpl_text, host=settings.BCPRINTER_PRINTER1_HOST): + """ + Sends zpl_text to printer + """ + ftp = ftplib.FTP(host=host, user='blank', passwd='') + ftp.login() + ftp.storlines("STOR printme.txt", StringIO.StringIO(zpl_text)) + ftp.quit() + + +def print_zpl_socket(zpl_text, host=settings.BCPRINTER_PRINTER1_HOST, port=settings.BCPRINTER_PRINTER1_PORT): + """ + Sends zpl_text to printer via a socket + """ + s = socket.socket() + # PORT 9100 is default for Zebra tabletop/desktop printers + # PORT 6101 is default for Zebra mobile printers + s.connect((host, port)) + s.sendall(zpl_text) + s.close() def report_error(message): """