In some occasions, the job end time might not be set (job stuck that had to be aborted, for example). If that happens, the operation t_end - t_begin used to get the job execution time will fail with an IndexError, since t_end is None. Handle that case properly.
Signed-off-by: Lucas Meneghel Rodrigues <[email protected]> --- scheduler/scheduler_models.py | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/scheduler/scheduler_models.py b/scheduler/scheduler_models.py index c302dac..7567415 100644 --- a/scheduler/scheduler_models.py +++ b/scheduler/scheduler_models.py @@ -939,11 +939,15 @@ class Job(DBObject): if time_row: t_begin, t_end = time_row[0] - delta = t_end - t_begin - minutes, seconds = divmod(delta.seconds, 60) - hours, minutes = divmod(minutes, 60) - stats['execution_time'] = ("%02d:%02d:%02d" % - (hours, minutes, seconds)) + try: + delta = t_end - t_begin + minutes, seconds = divmod(delta.seconds, 60) + hours, minutes = divmod(minutes, 60) + stats['execution_time'] = ("%02d:%02d:%02d" % + (hours, minutes, seconds)) + # One of t_end or t_begin are None + except TypeError: + stats['execution_time'] = '(could not determine)' else: stats['execution_time'] = '(none)' -- 1.7.2.3 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
