From e0ec0ff6c054d0507760793da8f4f22c125243fa Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 6 Oct 2008 13:40:52 +0000
Subject: [PATCH] Fix gnt-job list with empty timestamps

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 | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/cli.py b/lib/cli.py
index 71d010f71..71a995307 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -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
-- 
GitLab