diff mbox series

scripts/lib/buildstats: handle top-level build_stats not being complete

Message ID 20230323125404.1736319-1-ross.burton@arm.com
State Accepted, archived
Commit 701d985aa8f2e9c2b9c0736fa25b424f3701889e
Headers show
Series scripts/lib/buildstats: handle top-level build_stats not being complete | expand

Commit Message

Ross Burton March 23, 2023, 12:54 p.m. UTC
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 <ross.burton@arm.com>
---
 scripts/lib/buildstats.py | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/scripts/lib/buildstats.py b/scripts/lib/buildstats.py
index c9a238bb127..9f8c9061505 100644
--- a/scripts/lib/buildstats.py
+++ b/scripts/lib/buildstats.py
@@ -239,6 +239,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)