Revision 853e7f3d
b/lib/cli.py | ||
---|---|---|
405 | 405 |
if cl is None: |
406 | 406 |
cl = GetClient() |
407 | 407 |
|
408 |
state = None |
|
408 | 409 |
lastmsg = None |
409 | 410 |
while True: |
410 |
jobs = cl.QueryJobs([job_id], ["status", "ticker"])
|
|
411 |
if not jobs:
|
|
411 |
state = cl.WaitForJobChange(job_id, ["status", "ticker"], state)
|
|
412 |
if not state:
|
|
412 | 413 |
# job not found, go away! |
413 | 414 |
raise errors.JobLost("Job with id %s lost" % job_id) |
414 | 415 |
|
415 | 416 |
# TODO: Handle canceled and archived jobs |
416 |
status = jobs[0][0]
|
|
417 |
status = state[0]
|
|
417 | 418 |
if status in (constants.JOB_STATUS_SUCCESS, constants.JOB_STATUS_ERROR): |
418 | 419 |
break |
419 |
msg = jobs[0][1]
|
|
420 |
msg = state[1]
|
|
420 | 421 |
if msg is not None and msg != lastmsg: |
421 | 422 |
if callable(feedback_fn): |
422 | 423 |
feedback_fn(msg) |
423 | 424 |
else: |
424 | 425 |
print "%s %s" % (time.ctime(utils.MergeTime(msg[0])), msg[2]) |
425 | 426 |
lastmsg = msg |
426 |
time.sleep(1) |
|
427 | 427 |
|
428 | 428 |
jobs = cl.QueryJobs([job_id], ["status", "opresult"]) |
429 | 429 |
if not jobs: |
Also available in: Unified diff