bitbake: toaster: fixes for null values from events

Some of the data values may come of as None through the event system,
and the UI would encounter a problem saving the Configuration.
It would be trying to save these values as NULL in the
database, which is not allowed.

This patch adds more verification for data coming through
the event system.

Other minor updates:
* update for the event model from toaster.bbclass
* minor code flow fix in the event system

(Bitbake rev: 03fafd086381723c6486522873671515824e49f2)

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Alexandru DAMIAN 2013-11-01 15:58:28 +00:00 committed by Richard Purdie
parent d870d3e38a
commit f04a32162d
2 changed files with 19 additions and 24 deletions

View File

@ -171,7 +171,7 @@ class ORMWrapper(object):
return log_object.save()
def save_build_package_information(self, build_obj, package_info, recipes, files):
def save_build_package_information(self, build_obj, package_info, recipes):
# create and save the object
bp_object = Build_Package.objects.create( build = build_obj,
recipe = recipes[package_info['PN']],
@ -185,35 +185,33 @@ class ORMWrapper(object):
license = package_info['LICENSE'],
)
# save any attached file information
if bp_object.name in files.keys():
for path, size in files[bp_object.name]:
for path in package_info['FILES_INFO']:
fo = Build_File.objects.create( bpackage = bp_object,
path = path,
size = size )
del files[bp_object.name]
size = package_info['FILES_INFO'][path] )
# save soft dependency information
if package_info['RDEPENDS']:
if 'RDEPENDS' in package_info and package_info['RDEPENDS']:
for p in bb.utils.explode_deps(package_info['RDEPENDS']):
Build_Package_Dependency.objects.get_or_create( package = bp_object,
depends_on = p, dep_type = Build_Package_Dependency.TYPE_RDEPENDS)
if package_info['RPROVIDES']:
if 'RPROVIDES' in package_info and package_info['RPROVIDES']:
for p in bb.utils.explode_deps(package_info['RPROVIDES']):
Build_Package_Dependency.objects.get_or_create( package = bp_object,
depends_on = p, dep_type = Build_Package_Dependency.TYPE_RPROVIDES)
if package_info['RRECOMMENDS']:
if 'RRECOMMENDS' in package_info and package_info['RRECOMMENDS']:
for p in bb.utils.explode_deps(package_info['RRECOMMENDS']):
Build_Package_Dependency.objects.get_or_create( package = bp_object,
depends_on = p, dep_type = Build_Package_Dependency.TYPE_RRECOMMENDS)
if package_info['RSUGGESTS']:
if 'RSUGGESTS' in package_info and package_info['RSUGGESTS']:
for p in bb.utils.explode_deps(package_info['RSUGGESTS']):
Build_Package_Dependency.objects.get_or_create( package = bp_object,
depends_on = p, dep_type = Build_Package_Dependency.TYPE_RSUGGESTS)
if package_info['RREPLACES']:
if 'RREPLACES' in package_info and package_info['RREPLACES']:
for p in bb.utils.explode_deps(package_info['RREPLACES']):
Build_Package_Dependency.objects.get_or_create( package = bp_object,
depends_on = p, dep_type = Build_Package_Dependency.TYPE_RREPLACES)
if package_info['RCONFLICTS']:
if 'RCONFLICTS' in package_info and package_info['RCONFLICTS']:
for p in bb.utils.explode_deps(package_info['RCONFLICTS']):
Build_Package_Dependency.objects.get_or_create( package = bp_object,
depends_on = p, dep_type = Build_Package_Dependency.TYPE_RCONFLICTS)
@ -223,10 +221,16 @@ class ORMWrapper(object):
def save_build_variables(self, build_obj, vardump):
for k in vardump:
if not bool(vardump[k]['func']):
value = vardump[k]['v'];
if value is None:
value = ''
desc = vardump[k]['doc'];
if desc is None:
desc = ''
Variable.objects.create( build = build_obj,
variable_name = k,
variable_value = vardump[k]['v'],
description = vardump[k]['doc'])
variable_value = value,
description = desc)
class BuildInfoHelper(object):
@ -668,15 +672,7 @@ class BuildInfoHelper(object):
self.orm_wrapper.save_build_package_information(self.internal_state['build'],
package_info,
self.internal_state['recipes'],
self.internal_state['package_files'])
def store_package_file_information(self, event):
if not 'package_files' in self.internal_state.keys():
self.internal_state['package_files'] = {}
data = event.data
self.internal_state['package_files'][data['PKG']] = data['FILES']
)
def _store_log_information(self, level, text):
log_information = {}

View File

@ -140,6 +140,7 @@ def main(server, eventHandler, params ):
logfile = event.logfile
if logfile and os.path.exists(logfile):
bb.error("Logfile of failure stored in: %s" % logfile)
continue
# these events are unprocessed now, but may be used in the future to log
# timing and error informations from the parsing phase in Toaster
@ -230,8 +231,6 @@ def main(server, eventHandler, params ):
if isinstance(event, bb.event.MetadataEvent):
if event.type == "SinglePackageInfo":
buildinfohelper.store_build_package_information(event)
elif event.type == "PackageFileSize":
buildinfohelper.store_package_file_information(event)
continue
# ignore