-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_zebra.py
More file actions
62 lines (56 loc) · 2.16 KB
/
Copy pathclient_zebra.py
File metadata and controls
62 lines (56 loc) · 2.16 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
55
56
57
58
59
60
61
62
import argparse
from client import Client
from label_darwin import DarwinClientZebra
import io
from threading import Lock
import socket, select, sys
PG_CONNEX = "host='' dbname='darwin2' user='' password=''"
PORT = 8091
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
IP_SERVICE = args.user_ip
if RepresentsInt(specimenid) is True:
print("GO")
print(IP_SERVICE)
print(PORT)
label_tool = DarwinClientZebra()
label_tool.set_pg_connection(PG_CONNEX)
#fileprn = io.StringIO()
label_text = label_tool.define_and_print_label(specimenid)
#print(label_text)
#DarwinPrinterClient=Client(label_text, IP_SERVICE, PORT)
#DarwinPrinterClient.call_service()
#fileprn.close()
elif '_' in specimenid:
m_mutex = Lock()
label_tool = DarwinClientZebra()
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()
#fileprn = io.StringIO()
label_text=""
label_text = label_tool.define_and_print_label(p_id)
#DarwinPrinterClient=Client(label_text, IP_SERVICE, PORT)
#DarwinPrinterClient.call_service()
print("done");
#fileprn.close()
except Exception, e:
#TODO more efficent exception capture
print("Issue")
print("Unexpected error:", sys.exc_info()[0])
finally:
if m_mutex.locked():
m_mutex.release()