Fix gnt-job list with empty timestamps
authorIustin Pop <iustin@google.com>
Mon, 6 Oct 2008 13:40:52 +0000 (13:40 +0000)
committerIustin Pop <iustin@google.com>
Mon, 6 Oct 2008 13:40:52 +0000 (13:40 +0000)
In case the job object doesn't have a timestamp (which is a separate
issue), the listing should not break. We fix this by changing the
FormatTimstamp function itself to return '?' in case the timestamp
doesn't look good (note that it still can break if non-integers are
returned, but this is unlikely).

Reviewed-by: imsnah

lib/cli.py

index 71d010f..71a9953 100644 (file)
@@ -703,5 +703,7 @@ def FormatTimestamp(ts):
   @returns: a string with the formatted timestamp
 
   """
+  if not isinstance (ts, (tuple, list)) or len(ts) != 2:
+    return '?'
   sec, usec = ts
   return time.strftime("%F %T", time.localtime(sec)) + ".%06d" % usec