From de604832c3ece2aaeb56cc7a427dcb1dd833c0e1 Mon Sep 17 00:00:00 2001 From: TerryHowe Date: Mon, 1 Jun 2015 13:28:53 -0600 Subject: [PATCH] Catch exception trying to extract test time The database I am getting back is a gdm database and it does not have a get method. Catch the exception and try something else. If that blows up, ignore because we'd rather see the results of our tests. Change-Id: I2882e19d49f2fb3471669f5eb8a017c5d5ac98c2 --- os_testr/subunit_trace.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/os_testr/subunit_trace.py b/os_testr/subunit_trace.py index c509e43..960b476 100755 --- a/os_testr/subunit_trace.py +++ b/os_testr/subunit_trace.py @@ -131,7 +131,14 @@ def find_test_run_time_diff(test_id, run_time): test_times = dbm.open(times_db_path) except Exception: return False - avg_runtime = float(test_times.get(str(test_id), False)) + try: + avg_runtime = float(test_times.get(str(test_id), False)) + except Exception: + try: + avg_runtime = float(test_times[str(test_id)]) + except Exception: + avg_runtime = False + if avg_runtime and avg_runtime > 0: run_time = float(run_time.rstrip('s')) perc_diff = ((run_time - avg_runtime) / avg_runtime) * 100