]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
hob: Hob should display warnings generated during parsing
authorCristiana Voicu <cristiana.voicu@intel.com>
Mon, 21 Jan 2013 14:40:07 +0000 (16:40 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 21 Jan 2013 15:50:38 +0000 (15:50 +0000)
-now Hob catches the warnings generated during parsing, and after the parsing
is completed, if there are any warnings, it shows a bar that contains a message
with how many warnings has encountered, and a button "View warnings"
-when "View warnings" button is clicked, Hob shows a dialog with the warnings;
if there more than 1 warning, you can use "Previous" and "Next" button to see them

[YOCTO #3215]
Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/ui/crumbs/builder.py
lib/bb/ui/crumbs/hobcolor.py
lib/bb/ui/crumbs/hobeventhandler.py
lib/bb/ui/crumbs/imageconfigurationpage.py
lib/bb/ui/crumbs/packageselectionpage.py

index b783dad57fab4530987509f6960b16c53c97f018..d57cf4c32299260e2e7f70408a56de09169399d5 100755 (executable)
@@ -46,6 +46,7 @@ from bb.ui.crumbs.hig.advancedsettingsdialog import AdvancedSettingsDialog
 from bb.ui.crumbs.hig.deployimagedialog import DeployImageDialog
 from bb.ui.crumbs.hig.layerselectiondialog import LayerSelectionDialog
 from bb.ui.crumbs.hig.imageselectiondialog import ImageSelectionDialog
+from bb.ui.crumbs.hig.parsingwarningsdialog import ParsingWarningsDialog
 
 hobVer = 20120808
 
@@ -446,6 +447,9 @@ class Builder(gtk.Window):
         # Indicate whether the sanity check ran
         self.sanity_checked = False
 
+        # save parsing warnings
+        self.parsing_warnings = []
+
         # create visual elements
         self.create_visual_elements()
 
@@ -472,6 +476,7 @@ class Builder(gtk.Window):
         self.handler.connect("data-generated",           self.handler_data_generated_cb)
         self.handler.connect("command-succeeded",        self.handler_command_succeeded_cb)
         self.handler.connect("command-failed",           self.handler_command_failed_cb)
+        self.handler.connect("parsing-warning",          self.handler_parsing_warning_cb)
         self.handler.connect("sanity-failed",            self.handler_sanity_failed_cb)
         self.handler.connect("recipe-populated",         self.handler_recipe_populated_cb)
         self.handler.connect("package-populated",        self.handler_package_populated_cb)
@@ -880,6 +885,15 @@ class Builder(gtk.Window):
         response = dialog.run()
         dialog.destroy()
 
+    def show_warning_dialog(self):
+        dialog = ParsingWarningsDialog(title = "View warnings",
+                warnings = self.parsing_warnings,
+                parent = None,
+                flags = gtk.DIALOG_DESTROY_WITH_PARENT
+                       | gtk.DIALOG_NO_SEPARATOR)
+        response = dialog.run()
+        dialog.destroy()
+
     def show_network_error_dialog(self):
         lbl = "<b>Hob cannot connect to the network</b>\n"
         msg = "Please check your network connection. If you are using a proxy server, please make sure it is configured correctly."
@@ -903,6 +917,9 @@ class Builder(gtk.Window):
             self.show_error_dialog(msg)
         self.reset()
 
+    def handler_parsing_warning_cb(self, handler, warn_msg):
+        self.parsing_warnings.append(warn_msg)
+
     def handler_sanity_failed_cb(self, handler, msg, network_error):
         self.reset()
         if network_error:
index e10f546e52fa16237d13fbaf06ca619cbfdac44b..3316542a2058418ad1159222b80cb45ab969c4ba 100644 (file)
@@ -30,6 +30,7 @@ class HobColors:
     BLACK        = "#000000"
     PALE_BLUE    = "#53b8ff"
     DEEP_RED     = "#aa3e3e"
+    KHAKI        = "#fff68f"
 
     OK = WHITE
     RUNNING = PALE_GREEN
index e690d4c99c342fc1904ecbe5cb32a23995c819c1..41022ef8eb22c65c51db79af58343cb4463434fb 100644 (file)
@@ -41,6 +41,9 @@ class HobHandler(gobject.GObject):
          "command-failed"          : (gobject.SIGNAL_RUN_LAST,
                                       gobject.TYPE_NONE,
                                      (gobject.TYPE_STRING,)),
+         "parsing-warning"         : (gobject.SIGNAL_RUN_LAST,
+                                      gobject.TYPE_NONE,
+                                     (gobject.TYPE_STRING,)),
          "sanity-failed"           : (gobject.SIGNAL_RUN_LAST,
                                       gobject.TYPE_NONE,
                                      (gobject.TYPE_STRING, gobject.TYPE_INT)),
@@ -95,6 +98,7 @@ class HobHandler(gobject.GObject):
         self.server = server
         self.error_msg = ""
         self.initcmd = None
+        self.parsing = False
 
     def set_busy(self):
         if not self.generating:
@@ -207,6 +211,11 @@ class HobHandler(gobject.GObject):
                     formatter = bb.msg.BBLogFormatter()
                     msg = formatter.format(event)
                     self.error_msg += msg + '\n'
+                elif event.levelno >= logging.WARNING and self.parsing == True:
+                    formatter = bb.msg.BBLogFormatter()
+                    msg = formatter.format(event)
+                    warn_msg = msg + '\n'
+                    self.emit("parsing-warning", warn_msg)
 
         elif isinstance(event, bb.event.TargetsTreeGenerated):
             self.current_phase = "data generation"
@@ -249,6 +258,8 @@ class HobHandler(gobject.GObject):
             message["total"] = None
             message["title"] = "Parsing recipes"
             self.emit("parsing-started", message)
+            if isinstance(event, bb.event.ParseStarted):
+                self.parsing = True
         elif isinstance(event, (bb.event.ParseProgress,
                 bb.event.CacheLoadProgress,
                 bb.event.TreeDataPreparationProgress)):
@@ -267,6 +278,8 @@ class HobHandler(gobject.GObject):
             message["total"] = event.total
             message["title"] = "Parsing recipes"
             self.emit("parsing-completed", message)
+            if isinstance(event, bb.event.ParseCompleted):
+                self.parsing = False
         elif isinstance(event, bb.event.NetworkTestFailed):
             self.emit("network-failed")
             self.run_next_command()
index b94f35c66dfdf3df4759956bb84773eb9f008182..ff773501b043c5a5887c3e4660af9e122449c849 100644 (file)
@@ -46,6 +46,7 @@ class ImageConfigurationPage (HobPage):
         # cleared.
         self.machine_combo_changed_by_manual = True
         self.stopping = False
+        self.warning_shift = 0
         self.create_visual_elements()
 
     def create_visual_elements(self):
@@ -141,6 +142,37 @@ class ImageConfigurationPage (HobPage):
         if self.builder.recipe_model.get_selected_image() == self.builder.recipe_model.__custom_image__:
             self.just_bake_button.hide()
 
+    def add_warnings_bar(self):
+        #create the warnings bar shown when recipes parsing generates warnings
+        color = HobColors.KHAKI
+        warnings_bar = gtk.EventBox()
+        warnings_bar.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
+        warnings_bar.set_flags(gtk.CAN_DEFAULT)
+        warnings_bar.grab_default()
+
+        build_stop_tab = gtk.Table(10, 20, True)
+        warnings_bar.add(build_stop_tab)
+
+        icon = gtk.Image()
+        icon_pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_INDI_ALERT_FILE)
+        icon.set_from_pixbuf(icon_pix_buffer)
+        build_stop_tab.attach(icon, 0, 2, 0, 10)
+
+        label = gtk.Label()
+        label.set_alignment(0.0, 0.5)
+        warnings_nb = len(self.builder.parsing_warnings)
+        if warnings_nb == 1:
+            label.set_markup("<span size='x-large'><b>1 recipe parsing warning</b></span>")
+        else:
+            label.set_markup("<span size='x-large'><b>%s recipe parsing warnings</b></span>" % warnings_nb)
+        build_stop_tab.attach(label, 2, 12, 0, 10)
+
+        view_warnings_button = HobButton("View warnings")
+        view_warnings_button.connect('clicked', self.view_warnings_button_clicked_cb)
+        build_stop_tab.attach(view_warnings_button, 15, 19, 1, 9)
+
+        return warnings_bar
+
     def create_config_machine(self):
         self.machine_title = gtk.Label()
         self.machine_title.set_alignment(0.0, 0.5)
@@ -187,6 +219,12 @@ class ImageConfigurationPage (HobPage):
             #self.gtable.attach(self.progress_box, 0, 40, 15, 18)
             self.gtable.attach(self.progress_bar, 0, 37, 15, 18)
             self.gtable.attach(self.stop_button, 37, 40, 15, 18, 0, 0)
+        if self.builder.parsing_warnings:
+            self.warnings_bar = self.add_warnings_bar()
+            self.gtable.attach(self.warnings_bar, 0, 40, 14, 18)
+            self.warning_shift = 4
+        else:
+            self.warning_shift = 0
         self.gtable.attach(self.machine_separator, 0, 40, 13, 14)
 
     def create_config_baseimg(self):
@@ -222,12 +260,12 @@ class ImageConfigurationPage (HobPage):
         self.image_separator = gtk.HSeparator()
 
     def set_config_baseimg_layout(self):
-        self.gtable.attach(self.image_title, 0, 40, 15, 17)
-        self.gtable.attach(self.image_title_desc, 0, 40, 18, 22)
-        self.gtable.attach(self.image_combo, 0, 12, 23, 26)
-        self.gtable.attach(self.image_desc, 0, 12, 27, 33)
-        self.gtable.attach(self.view_adv_configuration_button, 14, 36, 23, 28)
-        self.gtable.attach(self.image_separator, 0, 40, 35, 36)
+        self.gtable.attach(self.image_title, 0, 40, 15+self.warning_shift, 17+self.warning_shift)
+        self.gtable.attach(self.image_title_desc, 0, 40, 18+self.warning_shift, 22+self.warning_shift)
+        self.gtable.attach(self.image_combo, 0, 12, 23+self.warning_shift, 26+self.warning_shift)
+        self.gtable.attach(self.image_desc, 0, 12, 27+self.warning_shift, 33+self.warning_shift)
+        self.gtable.attach(self.view_adv_configuration_button, 14, 36, 23+self.warning_shift, 28+self.warning_shift)
+        self.gtable.attach(self.image_separator, 0, 40, 35+self.warning_shift, 36+self.warning_shift)
 
     def create_config_build_button(self):
         # Create the "Build packages" and "Build image" buttons at the bottom
@@ -255,6 +293,9 @@ class ImageConfigurationPage (HobPage):
         self.progress_bar.set_rcstyle("stop")
         self.builder.cancel_parse_sync()
 
+    def view_warnings_button_clicked_cb(self, button):
+        self.builder.show_warning_dialog()
+
     def machine_combo_changed_cb(self, machine_combo):
         self.stopping = False
         combo_item = machine_combo.get_active_text()
@@ -435,6 +476,7 @@ class ImageConfigurationPage (HobPage):
             self.builder.reparse_post_adv_settings()        
 
     def just_bake_button_clicked_cb(self, button):
+        self.builder.parsing_warnings = []
         self.builder.just_bake()
 
     def edit_image_button_clicked_cb(self, button):
index 1868ebeddd19db8e7fac94ecaa0670c220adb76b..b879cc55db7d6e4c61c8f2856e5d8ad7b70db806 100755 (executable)
@@ -185,6 +185,7 @@ class PackageSelectionPage (HobPage):
         self.show_all()
 
     def build_image_clicked_cb(self, button):
+        self.builder.parsing_warnings = []
         self.builder.build_image()
 
     def back_button_clicked_cb(self, button):