Commit 3386e7a9 authored by Iustin Pop's avatar Iustin Pop
Browse files

Abstract the timestamp formatting into

Currently we format the timestamp inside the gnt-job info function. We
will need this more times in the future, so move it to as a
separate, exported function.

Reviewed-by: imsnah
parent b2cee5e5
......@@ -47,7 +47,7 @@ __all__ = ["DEBUG_OPT", "NOHDR_OPT", "SEP_OPT", "GenericMain",
"ListTags", "AddTags", "RemoveTags", "TAG_SRC_OPT",
"FormatError", "SplitNodeOption", "SubmitOrSend",
"JobSubmittedException", "FormatTimestamp",
......@@ -689,3 +689,17 @@ def GenerateTable(headers, fields, separator, data,
result.append(format % tuple(args))
return result
def FormatTimestamp(ts):
"""Formats a given timestamp.
@type ts: timestamp
@param ts: a timeval-type timestamp, a tuple of seconds and microseconds
@rtype: string
@returns: a string with the formatted timestamp
sec, usec = ts
return time.strftime("%F %T", time.localtime(sec)) + ".%06d" % usec
......@@ -178,8 +178,8 @@ def ShowJobs(opts, args):
format(3, "Result: %s" % result)
format(3, "Execution log:")
for serial, (sec, usec), log_type, log_msg in log:
time_txt = time.strftime("%F %T", time.localtime(sec)) + ".%06d" % usec
for serial, log_ts, log_type, log_msg in log:
time_txt = FormatTimestamp(log_ts)
encoded = str(log_msg).encode('string_escape')
format(4, "%s:%s:%s %s" % (serial, time_txt, log_type, encoded))
return 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment