bitbake: buildinfohelper: fix KeyError

When bitbake doesn't need to build anything it still sends
ImagePkgList event with empty 'pkgdata', 'imgdata' and 'filedata'
fields. This causes crash in buildinfohelper code as it's assumed
that above mentioned fields always have data keyed by build target:

ERROR: u'core-image-minimal'
Traceback (most recent call last):
  File "toasterui.py", line 423, in main
    buildinfohelper.store_target_package_data(event)
  File "buildinfohelper.py", line 1218, in store_target_package_data
    imgdata = BuildInfoHelper._get_data_from_event(event)['imgdata'][target.target]
KeyError: u'core-image-minimal'

Fixed this by using dict.get method with empty dictionary as default
return value instead of trying to get value without checking if target
key is in the data.

(Bitbake rev: c39cc463e6d9594bf2c5ac8bb74e834f6f2cf7c8)

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ed Bartosh 2016-04-06 17:46:47 +01:00 committed by Richard Purdie
parent 52c8740e1b
commit acb94078c4
1 changed files with 2 additions and 2 deletions

View File

@ -1231,8 +1231,8 @@ class BuildInfoHelper(object):
for target in self.internal_state['targets']:
if target.is_image:
pkgdata = BuildInfoHelper._get_data_from_event(event)['pkgdata']
imgdata = BuildInfoHelper._get_data_from_event(event)['imgdata'][target.target]
filedata = BuildInfoHelper._get_data_from_event(event)['filedata'][target.target]
imgdata = BuildInfoHelper._get_data_from_event(event)['imgdata'].get(target.target, {})
filedata = BuildInfoHelper._get_data_from_event(event)['filedata'].get(target.target, {})
try:
self.orm_wrapper.save_target_package_information(self.internal_state['build'], target, imgdata, pkgdata, self.internal_state['recipes'], built_package=True)