[oe-commits] [bitbake] 37/45: buildinfohelper: fix KeyError

git at git.openembedded.org git at git.openembedded.org
Wed Apr 6 22:11:55 UTC 2016


rpurdie pushed a commit to branch master
in repository bitbake.

commit c39cc463e6d9594bf2c5ac8bb74e834f6f2cf7c8
Author: Ed Bartosh <ed.bartosh at linux.intel.com>
AuthorDate: Wed Apr 6 17:46:47 2016 +0100

    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.
    
    Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
    Signed-off-by: Michael Wood <michael.g.wood at intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/ui/buildinfohelper.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/bb/ui/buildinfohelper.py b/lib/bb/ui/buildinfohelper.py
index 37a3fcb..9cb2c54 100644
--- a/lib/bb/ui/buildinfohelper.py
+++ b/lib/bb/ui/buildinfohelper.py
@@ -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)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list