Add job queued, started and finished timestamps to the tko db and
modify the parsing code to find these timestamps in the job keyval
file and insert them into the db.
Signed-off-by: John Admanski <jadmanski@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1246 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/tko/parse.py b/tko/parse.py
index 8a04f12..08fcb68 100755
--- a/tko/parse.py
+++ b/tko/parse.py
@@ -1,5 +1,5 @@
#!/usr/bin/python
-import os, re, md5, sys, email.Message, smtplib
+import os, re, md5, sys, email.Message, smtplib, datetime
client_bin = os.path.join(os.path.dirname(__file__), '../client/bin')
sys.path.insert(0, os.path.abspath(client_bin))
from autotest_utils import read_keyval
@@ -63,6 +63,13 @@
sys.stderr.write(str(info) + '\n')
+def keyval_timestamp(keyval, field):
+ val = keyval.get(field, None)
+ if val is not None:
+ val = datetime.datetime.fromtimestamp(int(val))
+ return val
+
+
class job:
def __init__(self, dir):
self.dir = dir
@@ -85,6 +92,9 @@
self.machine = keyval.get('hostname', None)
if self.machine:
assert ',' not in self.machine
+ self.queued_time = keyval_timestamp(keyval, 'job_queued')
+ self.started_time = keyval_timestamp(keyval, 'job_started')
+ self.finished_time = keyval_timestamp(keyval, 'job_finished')
self.machine_owner = keyval.get('owner', None)
if not self.machine: