- fname = args[0]
- op_data = simplejson.loads(open(fname).read())
- op_list = [opcodes.OpCode.LoadOpCode(val) for val in op_data]
- job = opcodes.Job(op_list=op_list)
- jid = SubmitJob(job)
- print "Job id:", jid
- query = {
- "object": "jobs",
- "fields": ["status"],
- "names": [jid],
- }
-
- # wait for job to complete (either by success or failure)
- while True:
- jdata = SubmitQuery(query)
- if not jdata:
- # job not found, gone away!
- print "Job lost!"
- return 1
-
- status = jdata[0][0]
- print status
- if status in (opcodes.Job.STATUS_SUCCESS, opcodes.Job.STATUS_FAIL):
- break
-
- # sleep between checks
- time.sleep(0.5)
-
- # job has finished, get and process its results
- query["fields"].extend(["op_list", "op_status", "op_result"])
- jdata = SubmitQuery(query)
- if not jdata:
- # job not found, gone away!
- print "Job lost!"
- return 1
- print jdata[0]
- status, op_list, op_status, op_result = jdata[0]
- for idx, op in enumerate(op_list):
- print idx, op.OP_ID, op_status[idx], op_result[idx]
+ cl = cli.GetClient()
+ job_data = []
+ job_ids = []
+ for fname in args:
+ op_data = simplejson.loads(open(fname).read())
+ op_list = [opcodes.OpCode.LoadOpCode(val) for val in op_data]
+ job_data.append((fname, op_list))
+ for fname, op_list in job_data:
+ jid = cli.SendJob(op_list, cl=cl)
+ ToStdout("File '%s', job id: %s", fname, jid)
+ job_ids.append(jid)
+ for jid in job_ids:
+ ToStdout("Waiting for job id %s", jid)
+ cli.PollJob(jid, cl=cl)