From 3293de79c6074996c19b9606b2b03ee77d45d1b3 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Thu, 5 Nov 2015 12:56:14 -0700 Subject: [PATCH] Format durations as HH:MM:SS Signed-off-by: Zack Cerza --- teuthology/results.py | 12 +++++++++--- teuthology/test/test_results.py | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/teuthology/results.py b/teuthology/results.py index 5c0ea7da7d..b5e210cd7b 100644 --- a/teuthology/results.py +++ b/teuthology/results.py @@ -175,7 +175,7 @@ def format_job(run_name, job): job_id = job['job_id'] status = job['status'] description = job['description'] - duration = int(job['duration'] or 0) + duration = seconds_to_hms(int(job['duration'] or 0)) # Every job gets a link to e.g. pulpito's pages info_url = misc.get_results_url(run_name, job_id) @@ -239,6 +239,12 @@ def format_job(run_name, job): return email_templates['fail_templ'].format(**format_args) +def seconds_to_hms(seconds): + (minutes, seconds) = divmod(seconds, 60) + (hours, minutes) = divmod(minutes, 60) + return "%02d:%02d:%02d" % (hours, minutes, seconds) + + email_templates = { 'body_templ': dedent("""\ Test Run: {name} @@ -262,7 +268,7 @@ email_templates = { 'fail_templ': dedent("""\ [{job_id}] {desc} ----------------------------------------------------------------- - time: {time}s{info_line}{log_line}{sentry_line}{reason_lines} + time: {time}{info_line}{log_line}{sentry_line}{reason_lines} """), 'info_url_templ': "\ninfo: {info}", @@ -274,7 +280,7 @@ email_templates = { """), 'pass_templ': dedent("""\ [{job_id}] {desc} - time: {time}s{info_line} + time: {time}{info_line} """), } diff --git a/teuthology/test/test_results.py b/teuthology/test/test_results.py index 00203ea61a..6dab00afb4 100644 --- a/teuthology/test/test_results.py +++ b/teuthology/test/test_results.py @@ -88,7 +88,7 @@ class TestResultsEmail(object): ================================================================= [88979] description for job with name test_name ----------------------------------------------------------------- - time: 35190s + time: 09:46:30 info: http://example.com/test_name/88979/ log: http://qa-proxy.ceph.com/teuthology/test_name/88979/ @@ -100,7 +100,7 @@ class TestResultsEmail(object): ================================================================= [69152] description for job with name test_name ----------------------------------------------------------------- - time: 5225s + time: 01:27:05 info: http://example.com/test_name/69152/ log: http://qa-proxy.ceph.com/teuthology/test_name/69152/ @@ -126,7 +126,7 @@ class TestResultsEmail(object): Pass ================================================================= [68369] description for job with name test_name - time: 33771s + time: 09:22:51 info: http://example.com/test_name/68369/ """).strip(), } -- 2.39.5