-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathgearmanjob.py
38 lines (33 loc) · 1.3 KB
/
gearmanjob.py
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
import gear
import json
import sys
from lib.logLib import *
def gearmanjob(gearman_srv_list, jobname, build_params):
client = gear.Client()
for item in gearman_srv_list:
item_list = item.split(":")
client.addServer(item_list[0], port = int(item_list[1]))
client.waitForServer() # Wait for at least one server to be connected
job = gear.Job('build:' + jobname, json.dumps(build_params))
client.submitJob(job)
if __name__ == '__main__':
try:
#gearman_srv_list = ['127.0.0.1:8899']
gearman_srv_list = sys.argv[1].split(",")
jobname = sys.argv[2]
build_params = json.loads(sys.argv[3])
for item in build_params:
'''try:
if(build_params[item]):
#tmpstr = json.dumps(build_params[item])
print build_params[item]
except Exception as e:
pass'''
if(type(build_params[item]) == list or type(build_params[item]) == dict):
'''print build_params[item]
print str(build_params[item])'''
build_params[item] = json.dumps(build_params[item])
#print build_params
gearmanjob(gearman_srv_list, jobname, build_params)
except Exception as e:
print(e)