Sample ID now generated partially base on primary key of sample.
[htsworkflow.git] / samplebc / samples / views.py
index 2d3825c0e4afa493fb52f59d14483fdc430ab482..677fedb38a10a208ad5b3226d08ce2e46377de99 100644 (file)
@@ -22,6 +22,7 @@ from reversion import revision
 
 import random
 import ftplib
+import socket
 import StringIO
 
 
@@ -37,7 +38,17 @@ def print_zpl(zpl_text):
     ftp.login()
     ftp.storlines("STOR printme.txt", StringIO.StringIO(zpl_text))
     ftp.quit()
-
+    
+def print_zpl_socket(zpl_text):
+    """
+    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((settings.PRINTER_HOST, settings.PRINTER_PORT))
+    s.sendall(zpl_text)
+    s.close()
 
 def __center_line(line, width):
     spaces_to_add = width - len(line)
@@ -498,7 +509,7 @@ def sample_add(request):
             s_obj = form.save(commit=False)
             
             # Add sample ID
-            s_obj.sampleid = get_sampleid()
+            #s_obj.sampleid = get_sampleid()
             
             # If the user wants us to assign a container.
             if form.cleaned_data['assign_container']: