From 39ac4c9711013caa3ed5a989eb1f79fe1d307120 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Jul 2018 00:50:20 +0200 Subject: [PATCH 1/2] Catch parsing error when time does not decode --- lib/ctt/report.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/ctt/report.py b/lib/ctt/report.py index 3a6b088..7c46bcd 100755 --- a/lib/ctt/report.py +++ b/lib/ctt/report.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# 2012 Nico Schottelius (nico-ctt at schottelius.org) +# 2012-2018 Nico Schottelius (nico-ctt at schottelius.org) # 2016 Darko Poljak (darko.poljak at gmail.com) # # This file is part of ctt. @@ -238,6 +238,7 @@ class Report(object): ''' report = {} start_datetime = datetime.datetime.strptime(time, ctt.DATETIMEFORMAT) + delta = datetime.timedelta(seconds=int(float(entry['delta']))) end_datetime = (start_datetime + delta).replace(microsecond=0) @@ -261,7 +262,13 @@ class Report(object): time_keys = self._report_db.keys() for time in time_keys: entry = self._report_db[time] - report = self._get_report_entry(time, entry) + + try: + report = self._get_report_entry(time, entry) + except ValueError as e: + log.error("Cannot parse entry {}: {}".format(time, e)) + sys.exit(1) + if time not in entries: entries[time] = [report] else: From 8d7da9aadefdee2bcfa0c4b921aea4b3ea6e8cf5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Jul 2018 00:53:20 +0200 Subject: [PATCH 2/2] add sys import for sys.exit --- lib/ctt/report.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ctt/report.py b/lib/ctt/report.py index 7c46bcd..17e8e61 100755 --- a/lib/ctt/report.py +++ b/lib/ctt/report.py @@ -30,6 +30,7 @@ import os.path import re import glob import collections +import sys import ctt import ctt.listprojects