[bitbake-devel] [PATCH 1/8] toaster: fixes for null values from events

Paul Eggleton paul.eggleton at linux.intel.com
Fri Nov 1 15:58:28 UTC 2013


From: Alexandru DAMIAN <alexandru.damian at intel.com>

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

Signed-off-by: Alexandru DAMIAN <alexandru.damian at intel.com>
---
 lib/bb/ui/buildinfohelper.py | 40 ++++++++++++++++++----------------------
 lib/bb/ui/toasterui.py       |  3 +--
 2 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/lib/bb/ui/buildinfohelper.py b/lib/bb/ui/buildinfohelper.py
index fbb2620..5881d13 100644
--- a/lib/bb/ui/buildinfohelper.py
+++ b/lib/bb/ui/buildinfohelper.py
@@ -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 = {}
diff --git a/lib/bb/ui/toasterui.py b/lib/bb/ui/toasterui.py
index ab87092..6c5b152 100644
--- a/lib/bb/ui/toasterui.py
+++ b/lib/bb/ui/toasterui.py
@@ -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
-- 
1.8.1.2




More information about the bitbake-devel mailing list