From eba1aaad86b15759f96f2250525122765856af19 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 28 Mar 2012 14:36:12 +0200 Subject: [PATCH] gnt-job info: Convert to query2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise detecting unavailable jobs is hard (βstatusβ is None, is this an error or just an unavailable job?). Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/client/gnt_job.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/client/gnt_job.py b/lib/client/gnt_job.py index 4d888ad83..58d5c5fd4 100644 --- a/lib/client/gnt_job.py +++ b/lib/client/gnt_job.py @@ -218,27 +218,26 @@ def ShowJobs(opts, args): "opstart", "opexec", "opend", "received_ts", "start_ts", "end_ts", ] - result = GetClient().QueryJobs(args, selected_fields) + result = GetClient().Query(constants.QR_JOB, selected_fields, + qlang.MakeSimpleFilter("id", args)).data first = True - for idx, entry in enumerate(result): + for entry in result: if not first: format_msg(0, "") else: first = False - if entry is None: - if idx <= len(args): - format_msg(0, "Job ID %s not found" % args[idx]) - else: - # this should not happen, when we don't pass args it will be a - # valid job returned - format_msg(0, "Job ID requested as argument %s not found" % (idx + 1)) + ((_, job_id), (rs_status, status), (_, ops), (_, opresult), (_, opstatus), + (_, oplog), (_, opstart), (_, opexec), (_, opend), (_, recv_ts), + (_, start_ts), (_, end_ts)) = entry + + # Detect non-normal results + if rs_status != constants.RS_NORMAL: + format_msg(0, "Job ID %s not found" % job_id) continue - (job_id, status, ops, opresult, opstatus, oplog, - opstart, opexec, opend, recv_ts, start_ts, end_ts) = entry format_msg(0, "Job ID: %s" % job_id) if status in _USER_JOB_STATUS: status = _USER_JOB_STATUS[status] -- GitLab