Initial port to python3
[htsworkflow.git] / htsworkflow / frontend / bcmagic / utils.py
index 78919b00f99a8a834b90884b219fc2145f2e9f68..0317ca7fa3370fa3ee9830ee3adc5a4649594ac5 100644 (file)
@@ -2,7 +2,7 @@ from django.conf import settings
 
 import ftplib
 import socket
-import StringIO
+import io
 
 
 def print_zpl(zpl_text, host=settings.BCPRINTER_PRINTER1_HOST):
@@ -11,22 +11,24 @@ def print_zpl(zpl_text, host=settings.BCPRINTER_PRINTER1_HOST):
     """
     ftp = ftplib.FTP(host=host, user='blank', passwd='')
     ftp.login()
-    ftp.storlines("STOR printme.txt", StringIO.StringIO(zpl_text))
+    ftp.storlines("STOR printme.txt", io.StringIO(zpl_text))
     ftp.quit()
-    
 
-def print_zpl_socket(zpl_text, host=settings.BCPRINTER_PRINTER1_HOST, port=settings.BCPRINTER_PRINTER1_PORT):
+
+def print_zpl_socket(zpl_text,
+                     host=settings.BCPRINTER_PRINTER1_HOST,
+                     port=settings.BCPRINTER_PRINTER1_PORT):
     """
     Sends zpl_text to printer via a socket
-    
+
     if zpl_text is a list of zpl_texts, it will print each one
     in that list.
     """
-    
+
     # Process anyway if zpl_text is a list.
     if type(zpl_text) is list:
         zpl_text = '\n'.join(zpl_text)
-    
+
     s = socket.socket()
     # PORT 9100 is default for Zebra tabletop/desktop printers
     # PORT 6101 is default for Zebra mobile printers
@@ -34,19 +36,20 @@ def print_zpl_socket(zpl_text, host=settings.BCPRINTER_PRINTER1_HOST, port=setti
     s.sendall(zpl_text)
     s.close()
 
+
 def report_error(message):
     """
     Return a dictionary with a command to display 'message'
     """
     return {'mode': 'Error', 'status': message}
-    
+
 
 def redirect_to_url(url):
     """
     Return a bcm dictionary with a command to redirect to 'url'
     """
     return {'mode': 'redirect', 'url': url}
-    
+
 
 def autofill(field, value):
     """