[gnome-continuous-yocto/gnomeostree-3.28-rocko: 6176/8267] buildstats-diff: show more graceful error messages
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 6176/8267] buildstats-diff: show more graceful error messages
- Date: Sun, 17 Dec 2017 04:28:38 +0000 (UTC)
commit a93ec352a378af76795397aef0328322dd1cb405
Author: Ming Liu <peter x liu external atlascopco com>
Date: Tue Jun 6 05:19:43 2017 +0200
buildstats-diff: show more graceful error messages
I got a following error when I run buildstats-diff against a invalid
buildstats file:
| Traceback (most recent call last):
| File "/poky/scripts/buildstats-diff", line 548, in <module>
| sys.exit(main())
| File "/poky/scripts/buildstats-diff", line 534, in main
| bs1 = read_buildstats(args.buildstats1, args.multi)
| File "/poky/scripts/buildstats-diff", line 222, in read_buildstats
| return read_buildstats_dir(path)
| File "/poky/scripts/buildstats-diff", line 165, in read_buildstats_dir
| os.path.join(recipe_dir, task))]
| File "/poky/scripts/buildstats-diff", line 124, in read_buildstats_file
| bs_task['elapsed_time'] = end_time - start_time
| UnboundLocalError: local variable 'end_time' referenced before assignment
the root cause is that a task was terminated by me on the terminal,
so the generated buildstats file was invalid, supposing that it would
make the buildstats.sh fail, but the script should give more graceful
error messages.
(From OE-Core rev: dee3c29071017b4d12c02b711c5e42ca96e0578d)
Signed-off-by: Ming Liu <peter x liu external atlascopco com>
Signed-off-by: Ross Burton <ross burton intel com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
scripts/buildstats-diff | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/scripts/buildstats-diff b/scripts/buildstats-diff
index 4276464..8e64480 100755
--- a/scripts/buildstats-diff
+++ b/scripts/buildstats-diff
@@ -97,6 +97,7 @@ def read_buildstats_file(buildstat_file):
"""Convert buildstat text file into dict/json"""
bs_task = BSTask()
log.debug("Reading task buildstats from %s", buildstat_file)
+ end_time = None
with open(buildstat_file) as fobj:
for line in fobj.readlines():
key, val = line.split(':', 1)
@@ -121,7 +122,10 @@ def read_buildstats_file(buildstat_file):
bs_task[ru_type][ru_key] = val
elif key == 'Status':
bs_task['status'] = val
- bs_task['elapsed_time'] = end_time - start_time
+ if end_time is not None and start_time is not None:
+ bs_task['elapsed_time'] = end_time - start_time
+ else:
+ raise ScriptError("{} looks like a invalid buildstats file".format(buildstat_file))
return bs_task
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]