Revision 76b62028 lib/client/gnt_job.py
b/lib/client/gnt_job.py | ||
---|---|---|
1 | 1 |
# |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2006, 2007 Google Inc. |
|
4 |
# Copyright (C) 2006, 2007, 2012 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
60 | 60 |
raise errors.ProgrammerError("Unknown job status code '%s'" % value) |
61 | 61 |
|
62 | 62 |
|
63 |
def _ParseJobIds(args): |
|
64 |
"""Parses a list of string job IDs into integers. |
|
65 |
|
|
66 |
@param args: list of strings |
|
67 |
@return: list of integers |
|
68 |
@raise OpPrereqError: in case of invalid values |
|
69 |
|
|
70 |
""" |
|
71 |
try: |
|
72 |
return [int(a) for a in args] |
|
73 |
except (ValueError, TypeError), err: |
|
74 |
raise errors.OpPrereqError("Invalid job ID passed: %s" % err, |
|
75 |
errors.ECODE_INVAL) |
|
76 |
|
|
77 |
|
|
63 | 78 |
def ListJobs(opts, args): |
64 | 79 |
"""List the jobs |
65 | 80 |
|
... | ... | |
85 | 100 |
opts.separator, not opts.no_headers, |
86 | 101 |
format_override=fmtoverride, verbose=opts.verbose, |
87 | 102 |
force_filter=opts.force_filter, namefield="id", |
88 |
qfilter=qfilter) |
|
103 |
qfilter=qfilter, isnumeric=True)
|
|
89 | 104 |
|
90 | 105 |
|
91 | 106 |
def ListJobFields(opts, args): |
... | ... | |
203 | 218 |
"opstart", "opexec", "opend", "received_ts", "start_ts", "end_ts", |
204 | 219 |
] |
205 | 220 |
|
206 |
result = GetClient().Query(constants.QR_JOB, selected_fields,
|
|
207 |
qlang.MakeSimpleFilter("id", args)).data
|
|
221 |
qfilter = qlang.MakeSimpleFilter("id", _ParseJobIds(args))
|
|
222 |
result = GetClient().Query(constants.QR_JOB, selected_fields, qfilter).data
|
|
208 | 223 |
|
209 | 224 |
first = True |
210 | 225 |
|
Also available in: Unified diff