From 9f912f202317db9040ccded36b0795f6cedd9124 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Sun, 22 Jan 2023 22:59:28 +0100 Subject: show date and duration in human readable format Signed-off-by: Olivier Gayot --- app.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index 6753b38..6585f47 100644 --- a/app.py +++ b/app.py @@ -1,3 +1,4 @@ +import datetime import io import json import tarfile @@ -90,7 +91,7 @@ def index_release(LPUSER, PPA, PACKAGE, RELEASE): -def human_exitcode(code: int): +def human_exitcode(code: int) -> str: if code in (0, 2): return 'pass' if code in (4, 6, 12): @@ -106,6 +107,10 @@ def human_exitcode(code: int): return 'exit code %i' % code +def human_sec(secs: int) -> str: + return '%ih %02im %02is' % (secs // 3600, (secs % 3600) // 60, secs % 60) + + @app.route("/////") def index_results(LPUSER, PPA, PACKAGE, RELEASE, ARCH): @@ -146,8 +151,8 @@ def index_results(LPUSER, PPA, PACKAGE, RELEASE, ARCH): result = { "version": version, "triggers": triggers, - "date": date, - "duration": duration, + "date": datetime.datetime.strptime(date, "%Y%m%d %H%M%S").isoformat(), + "duration": human_sec(duration), "requester": requester, "result": human_exitcode(exitcode), "url_prefix": f"{autopkgtest_url_base}/{idx}", -- cgit v1.2.3