From: Ross Burton Date: Thu, 23 Mar 2023 12:54:04 +0000 (+0000) Subject: scripts/lib/buildstats: handle top-level build_stats not being complete X-Git-Tag: 2023-04-mickledore~128 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=701d985aa8f2e9c2b9c0736fa25b424f3701889e;p=thirdparty%2Fopenembedded%2Fopenembedded-core.git scripts/lib/buildstats: handle top-level build_stats not being complete If we try to parse a buildstats directory which was either aborted or is still being built then the top-level build_stats file doesn't contain an elapsed value which causes an exception: UnboundLocalError: local variable 'elapsed' referenced before assignment Default both start and elapsed to 0 so that the parse succeeds. Signed-off-by: Ross Burton Signed-off-by: Alexandre Belloni --- diff --git a/scripts/lib/buildstats.py b/scripts/lib/buildstats.py index fa94c655399..6db60d5bcf2 100644 --- a/scripts/lib/buildstats.py +++ b/scripts/lib/buildstats.py @@ -234,6 +234,7 @@ class BuildStats(dict): """ Parse the top-level build_stats file for build-wide start and duration. """ + start = elapsed = 0 with open(path) as fobj: for line in fobj.readlines(): key, val = line.split(':', 1)