Fix gnt-job list argument handling
authorGuido Trotter <ultrotter@google.com>
Mon, 18 May 2009 15:57:25 +0000 (16:57 +0100)
committerGuido Trotter <ultrotter@google.com>
Mon, 18 May 2009 16:39:56 +0000 (17:39 +0100)
Currently QueryJob returns "None" when a wrong job ID is passed.
Handle this in gnt-job list, by printing an error for each wrong job,
and still giving output for all the jobs which actually do exist.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/cli.py
scripts/gnt-job

index 6db7cea..17dc47c 100644 (file)
@@ -815,6 +815,8 @@ def GenerateTable(headers, fields, separator, data,
     format = separator.replace("%", "%%").join(format_fields)
 
   for row in data:
+    if row is None:
+      continue
     for idx, val in enumerate(row):
       if unitfields.Matches(fields[idx]):
         try:
@@ -840,6 +842,8 @@ def GenerateTable(headers, fields, separator, data,
 
   for line in data:
     args = []
+    if line is None:
+      line = ['-' for _ in fields]
     for idx in xrange(len(fields)):
       if separator is None:
         args.append(mlens[idx])
index ce81709..2da75a3 100755 (executable)
@@ -85,7 +85,11 @@ def ListJobs(opts, args):
     headers = None
 
   # change raw values to nicer strings
-  for row in output:
+  for row_id, row in enumerate(output):
+    if row is None:
+      ToStderr("No such job: %s" % args[row_id])
+      continue
+
     for idx, field in enumerate(selected_fields):
       val = row[idx]
       if field == "status":