@return: the desired exit code
"""
- if opts.output is None:
- selected_fields = _LIST_DEF_FIELDS
- elif opts.output.startswith("+"):
- selected_fields = _LIST_DEF_FIELDS + opts.output[1:].split(",")
- else:
- selected_fields = opts.output.split(",")
+ selected_fields = ParseFields(opts.output, _LIST_DEF_FIELDS)
output = GetClient().QueryJobs(args, selected_fields)
if not opts.no_headers:
headers = {
"id": "ID",
"status": "Status",
+ "priority": "Prio",
"ops": "OpCodes",
"opresult": "OpCode_result",
"opstatus": "OpCode_status",
"opstart": "OpCode_start",
"opexec": "OpCode_exec",
"opend": "OpCode_end",
+ "oppriority": "OpCode_prio",
"start_ts": "Start",
"end_ts": "End",
"received_ts": "Received",
else:
headers = None
+ numfields = ["priority"]
+
# change raw values to nicer strings
for row_id, row in enumerate(output):
if row is None:
row[idx] = str(val)
data = GenerateTable(separator=opts.separator, headers=headers,
- fields=selected_fields, data=output)
+ fields=selected_fields, data=output,
+ numfields=numfields)
for line in data:
ToStdout(line)
"""
client = GetClient()
+ result = constants.EXIT_SUCCESS
for job_id in args:
- (_, msg) = client.CancelJob(job_id)
+ (success, msg) = client.CancelJob(job_id)
+
+ if not success:
+ result = constants.EXIT_FAILURE
+
ToStdout(msg)
- # TODO: Different exit value if not all jobs were canceled?
- return 0
+ return result
def ShowJobs(opts, args):
else:
format_msg(3, "No processing end time")
format_msg(3, "Input fields:")
- for key, val in opcode.iteritems():
+ for key in utils.NiceSort(opcode.keys()):
if key == "OP_ID":
continue
+ val = opcode[key]
if isinstance(val, (tuple, list)):
val = ",".join([str(item) for item in val])
format_msg(4, "%s: %s" % (key, val))