summaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2023-01-22 22:59:28 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2023-01-22 22:59:28 +0100
commit9f912f202317db9040ccded36b0795f6cedd9124 (patch)
tree33497ed7a13ef8880786d8ae8650cf20a9de7f6b /app.py
parenta7f80c9e08dfaad2a6682938f88406ccc07b5732 (diff)
show date and duration in human readable format
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'app.py')
-rw-r--r--app.py11
1 files changed, 8 insertions, 3 deletions
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("/<LPUSER>/<PPA>/<PACKAGE>/<RELEASE>/<ARCH>")
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}",