From c39cc463e6d9594bf2c5ac8bb74e834f6f2cf7c8 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Wed, 6 Apr 2016 17:46:47 +0100 Subject: [PATCH] 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 Signed-off-by: Michael Wood Signed-off-by: Richard Purdie --- 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 37a3fcb9c74..9cb2c540671 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) -- 2.47.3