-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcall_zebra.py
More file actions
54 lines (49 loc) · 1.89 KB
/
Copy pathcall_zebra.py
File metadata and controls
54 lines (49 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/python3
import sys
sys.path.append('/var/thermic_printer_zebra/')
import argparse
from threading import Lock
import sys
from label_darwin import DarwinClientZebra
import time
PG_CONNEX = "host='' dbname='' user='' password='darwin123'"
def RepresentsInt(s):
try:
int(s)
return True
except ValueError:
return False
if __name__ =='__main__':
parser = argparse.ArgumentParser(description='Darwin Avery Dennison print spooler')
parser.add_argument('--specimen_id', '-s', help='darwin2 specimen id')
parser.add_argument('--user_ip', '-i', help='darwin2 user ip')
args= parser.parse_args()
specimenid = args.specimen_id
if '_' in specimenid:
print("serie")
m_mutex = Lock()
#label_tool = DarwinClientParser(LOGFILE)
#label_tool.set_pg_connection(PG_CONNEX)
for p_id in specimenid.split("_") :
if RepresentsInt(p_id) is True:
try:
print("launched");
m_mutex.acquire()
time.sleep(2)
#fileprn = io.StringIO()
label_tool = DarwinClientZebra()
label_tool.set_pg_connection(PG_CONNEX)
label_text = label_tool.define_and_print_label(p_id)
#fileprn.close()
except Exception as e:
#TODO more efficent exception capture
print("Issue")
print("Unexpected error:", sys.exc_info()[0])
finally:
if m_mutex.locked():
m_mutex.release()
elif RepresentsInt(specimenid) is True:
print("GO")
label_tool = DarwinClientZebra()
label_tool.set_pg_connection(PG_CONNEX)
label_text = label_tool.define_and_print_label(specimenid)