From 6cb70317130cab78809b63fff0f640b74ebe5225 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Mon, 21 May 2018 17:01:26 +0100 Subject: [PATCH] wa/misc: Fix format_duration() to handle missing time If a run is interrupted this can cause the time to be `None` causing an error, if this is the case then set time to 0 and therefore return `N/A`. --- wa/utils/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wa/utils/misc.py b/wa/utils/misc.py index e189b20c..9caf7b3b 100644 --- a/wa/utils/misc.py +++ b/wa/utils/misc.py @@ -247,7 +247,7 @@ def format_duration(seconds, sep=' ', order=['day', 'hour', 'minute', 'second']) if isinstance(seconds, timedelta): td = seconds else: - td = timedelta(seconds=seconds) + td = timedelta(seconds=seconds or 0) dt = datetime(1, 1, 1) + td result = [] for item in order: