Revision e9d741b6 lib/cli.py
b/lib/cli.py | ||
---|---|---|
47 | 47 |
"USEUNITS_OPT", "FIELDS_OPT", "FORCE_OPT", "SUBMIT_OPT", |
48 | 48 |
"ListTags", "AddTags", "RemoveTags", "TAG_SRC_OPT", |
49 | 49 |
"FormatError", "SplitNodeOption", "SubmitOrSend", |
50 |
"JobSubmittedException", |
|
50 | 51 |
] |
51 | 52 |
|
52 | 53 |
|
... | ... | |
374 | 375 |
return answer |
375 | 376 |
|
376 | 377 |
|
378 |
class JobSubmittedException(Exception): |
|
379 |
"""Job was submitted, client should exit. |
|
380 |
|
|
381 |
This exception has one argument, the ID of the job that was |
|
382 |
submitted. The handler should print this ID. |
|
383 |
|
|
384 |
This is not an error, just a structured way to exit from clients. |
|
385 |
|
|
386 |
""" |
|
387 |
|
|
388 |
|
|
377 | 389 |
def SendJob(ops, cl=None): |
378 | 390 |
"""Function to submit an opcode without waiting for the results. |
379 | 391 |
|
... | ... | |
471 | 483 |
|
472 | 484 |
""" |
473 | 485 |
if opts and opts.submit_only: |
474 |
print SendJob([op], cl=cl)
|
|
475 |
sys.exit(0)
|
|
486 |
job_id = SendJob([op], cl=cl)
|
|
487 |
raise JobSubmittedException(job_id)
|
|
476 | 488 |
else: |
477 | 489 |
return SubmitOpCode(op, cl=cl, feedback_fn=feedback_fn) |
478 | 490 |
|
... | ... | |
546 | 558 |
elif isinstance(err, luxi.ProtocolError): |
547 | 559 |
obuf.write("Unhandled protocol error while talking to the master daemon:\n" |
548 | 560 |
"%s" % msg) |
561 |
elif isinstance(err, JobSubmittedException): |
|
562 |
obuf.write("JobID: %s\n" % err.args[0]) |
|
563 |
retcode = 0 |
|
549 | 564 |
else: |
550 | 565 |
obuf.write("Unhandled exception: %s" % msg) |
551 | 566 |
return retcode, obuf.getvalue().rstrip('\n') |
Also available in: Unified diff