summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMing Liu <peter.x.liu@external.atlascopco.com>2017-06-06 05:19:43 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-09 17:12:14 +0100
commita93ec352a378af76795397aef0328322dd1cb405 (patch)
tree19e146813b4e1ae46f64516a8912397d5e350c28 /scripts
parent24b7e71350316d81e0f7eb5c11e2d5014adfd50f (diff)
downloadpoky-a93ec352a378af76795397aef0328322dd1cb405.tar.gz
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>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/buildstats-diff6
1 files changed, 5 insertions, 1 deletions
diff --git a/scripts/buildstats-diff b/scripts/buildstats-diff
index 4276464714..8e64480eb3 100755
--- a/scripts/buildstats-diff
+++ b/scripts/buildstats-diff
@@ -97,6 +97,7 @@ def read_buildstats_file(buildstat_file):
97 """Convert buildstat text file into dict/json""" 97 """Convert buildstat text file into dict/json"""
98 bs_task = BSTask() 98 bs_task = BSTask()
99 log.debug("Reading task buildstats from %s", buildstat_file) 99 log.debug("Reading task buildstats from %s", buildstat_file)
100 end_time = None
100 with open(buildstat_file) as fobj: 101 with open(buildstat_file) as fobj:
101 for line in fobj.readlines(): 102 for line in fobj.readlines():
102 key, val = line.split(':', 1) 103 key, val = line.split(':', 1)
@@ -121,7 +122,10 @@ def read_buildstats_file(buildstat_file):
121 bs_task[ru_type][ru_key] = val 122 bs_task[ru_type][ru_key] = val
122 elif key == 'Status': 123 elif key == 'Status':
123 bs_task['status'] = val 124 bs_task['status'] = val
124 bs_task['elapsed_time'] = end_time - start_time 125 if end_time is not None and start_time is not None:
126 bs_task['elapsed_time'] = end_time - start_time
127 else:
128 raise ScriptError("{} looks like a invalid buildstats file".format(buildstat_file))
125 return bs_task 129 return bs_task
126 130
127 131