Skip to contentSkip to conversation

hob:bug-fixes

PATCH New Liming An 1 participant 3 messages Aug 2, 2012

lore
Share & tools
lore

Liming An

author
#0 lore raw

cover hob:bug-fixes

The following changes since commit 62d42fe3cfa575cb97b484ccf7b2e9a25cc50770:

tiny-init: Setup /dev/ptmx in init (2012-08-01 23:11:18 +0100)

are available in the git repository at:
git://git.pokylinux.org/poky-contrib limx/hob-bug-fixes-continue
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=limx/hob-bug-fixes-continue

Liming An (2):
Hob: log for Hob and allow users to show logs after successful build
Hob: change the Build failure scenario as ui design

 bitbake/lib/bb/ui/crumbs/builddetailspage.py     |   83 +++++++++-------------
 bitbake/lib/bb/ui/crumbs/builder.py              |   52 +++++++++++---
 bitbake/lib/bb/ui/crumbs/hobeventhandler.py      |    3 +
 bitbake/lib/bb/ui/crumbs/imagedetailspage.py     |   24 +++++-
 bitbake/lib/bb/ui/crumbs/packageselectionpage.py |   27 ++++++-
 bitbake/lib/bb/ui/crumbs/runningbuild.py         |   41 +++++++++++
 6 files changed, 162 insertions(+), 68 deletions(-)
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH 1/2 Hob: log for Hob and allow users to show logs after successful build

If users build images in Hob, record logs and allow users to retrieve the lo after successful build.

The logs are generated if and only if:
- users do "just bake"
- users do "build image" after "build packages"
- users do "build packages" only

[YOCTO #1991]

---
 bitbake/lib/bb/ui/crumbs/builder.py              |   52 +++++++++++++++++----
 bitbake/lib/bb/ui/crumbs/hobeventhandler.py      |    3 +
 bitbake/lib/bb/ui/crumbs/imagedetailspage.py     |   24 ++++++++--
 bitbake/lib/bb/ui/crumbs/packageselectionpage.py |   27 ++++++++++--
 bitbake/lib/bb/ui/crumbs/runningbuild.py         |   41 +++++++++++++++++
 5 files changed, 129 insertions(+), 18 deletions(-)
bitbake/lib/bb/ui/crumbs/builder.py +42 -10
index 123608e..6e5e532 100755
@@ -27,6 +27,7 @@ import os
 import subprocess
 import shlex
 import re
+import logging
 from bb.ui.crumbs.template import TemplateMgr
 from bb.ui.crumbs.imageconfigurationpage import ImageConfigurationPage
 from bb.ui.crumbs.recipeselectionpage import RecipeSelectionPage
@@ -395,6 +396,11 @@ class Builder(gtk.Window):
 
         self.template = None
 
+        # logger
+        self.logger = logging.getLogger("BitBake")
+        self.consolelog = None
+        self.current_logfile = None
+
         # configuration and parameters
         self.configuration = Configuration()
         self.parameters = Parameters()
@@ -432,6 +438,7 @@ class Builder(gtk.Window):
         self.handler.build.connect("build-failed",       self.handler_build_failed_cb)
         self.handler.build.connect("task-started",       self.handler_task_started_cb)
         self.handler.build.connect("log-error",          self.handler_build_failure_cb)
+        self.handler.build.connect("log",                self.handler_build_log_cb)
         self.handler.build.connect("no-provider",        self.handler_no_provider_cb)
         self.handler.connect("generating-data",          self.handler_generating_data_cb)
         self.handler.connect("data-generated",           self.handler_data_generated_cb)
@@ -500,25 +507,34 @@ class Builder(gtk.Window):
         self.set_user_config()
         self.handler.generate_recipes()
 
-    def generate_packages_async(self):
+    def generate_packages_async(self, log = False):
         self.switch_page(self.PACKAGE_GENERATING)
+        if log:
+            self.current_logfile = self.handler.get_logfile()
+            self.do_log(self.current_logfile)
         # Build packages
         _, all_recipes = self.recipe_model.get_selected_recipes()
         self.set_user_config()
         self.handler.reset_build()
         self.handler.generate_packages(all_recipes, self.configuration.default_task)
 
-    def fast_generate_image_async(self):
+    def fast_generate_image_async(self, log = False):
         self.switch_page(self.FAST_IMAGE_GENERATING)
+        if log:
+            self.current_logfile = self.handler.get_logfile()
+            self.do_log(self.current_logfile)
         # Build packages
         _, all_recipes = self.recipe_model.get_selected_recipes()
         self.set_user_config()
         self.handler.reset_build()
         self.handler.generate_packages(all_recipes, self.configuration.default_task)
 
-    def generate_image_async(self):
+    def generate_image_async(self, cont = False):
         self.switch_page(self.IMAGE_GENERATING)
         self.handler.reset_build()
+        if not cont:
+            self.current_logfile = self.handler.get_logfile()
+            self.do_log(self.current_logfile)
         # Build image
         self.set_user_config()
         toolchain_packages = []
@@ -626,14 +642,14 @@ class Builder(gtk.Window):
             pass
 
         elif next_step == self.PACKAGE_SELECTION:
-            pass
+            self.package_details_page.show_page(self.current_logfile)
 
         elif next_step == self.PACKAGE_GENERATING or next_step == self.FAST_IMAGE_GENERATING:
             # both PACKAGE_GENEATING and FAST_IMAGE_GENERATING share the same page
             self.build_details_page.show_page(next_step)
 
         elif next_step == self.PACKAGE_GENERATED:
-            pass
+            self.package_details_page.show_page(self.current_logfile)
 
         elif next_step == self.IMAGE_GENERATING:
             # after packages are generated, selected_packages need to
@@ -735,7 +751,7 @@ class Builder(gtk.Window):
 
             self.rcppkglist_populated()
             if self.current_step == self.FAST_IMAGE_GENERATING:
-                self.generate_image_async()
+                self.generate_image_async(True)
 
     def show_error_dialog(self, msg):
         lbl = "<b>Error</b>\n"
@@ -959,6 +975,10 @@ class Builder(gtk.Window):
     def handler_build_failure_cb(self, running_build):
         self.build_details_page.show_issues()
 
+    def handler_build_log_cb(self, running_build, func, obj):
+        if hasattr(self.logger, func):
+            getattr(self.logger, func)(obj)
+
     def destroy_window_cb(self, widget, event):
         if not self.sensitive:
             return True
@@ -988,7 +1008,7 @@ class Builder(gtk.Window):
             dialog.run()
             dialog.destroy()
             return
-        self.generate_packages_async()
+        self.generate_packages_async(True)
 
     def build_image(self):
         selected_packages = self.package_model.get_selected_packages()
@@ -1001,7 +1021,7 @@ class Builder(gtk.Window):
             dialog.run()
             dialog.destroy()
             return
-        self.generate_image_async()
+        self.generate_image_async(True)
 
     def just_bake(self):
         selected_image = self.recipe_model.get_selected_image()
@@ -1018,7 +1038,7 @@ class Builder(gtk.Window):
             dialog.destroy()
             return
 
-        self.fast_generate_image_async()
+        self.fast_generate_image_async(True)
 
     def show_binb_dialog(self, binb):
         markup = "<b>Brought in by:</b>\n%s" % binb
@@ -1237,7 +1257,7 @@ class Builder(gtk.Window):
             response = dialog.run()
             dialog.destroy()
             if response == gtk.RESPONSE_YES:
-                self.generate_packages_async()
+                self.generate_packages_async(True)
             else:
                 self.switch_page(self.PACKAGE_SELECTION)
         else:
@@ -1285,3 +1305,15 @@ class Builder(gtk.Window):
             self.cancel_build_sync()
         elif response == gtk.RESPONSE_YES:
             self.cancel_build_sync(True)
+
+    def do_log(self, consolelogfile = None):
+        if consolelogfile:
+            if self.consolelog:
+                self.logger.removeHandler(self.consolelog)
+                self.consolelog = None
+            self.consolelog = logging.FileHandler(consolelogfile)
+            bb.msg.addDefaultlogFilter(self.consolelog)
+            format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
+            self.consolelog.setFormatter(format)
+
+            self.logger.addHandler(self.consolelog)
\ No newline at end of file
bitbake/lib/bb/ui/crumbs/hobeventhandler.py +3 -0
index a00fcd8..540dde0 100644
@@ -390,6 +390,9 @@ class HobHandler(gobject.GObject):
     def reset_build(self):
         self.build.reset()
 
+    def get_logfile(self):
+        return self.server.runCommand(["getVariable", "BB_CONSOLELOG"])
+
     def _remove_redundant(self, string):
         ret = []
         for i in string.split():
bitbake/lib/bb/ui/crumbs/imagedetailspage.py +20 -4
index 596fb85..40eb7a4 100755
@@ -33,7 +33,7 @@ from bb.ui.crumbs.hig import CrumbsDialog
 class ImageDetailsPage (HobPage):
 
     class DetailBox (gtk.EventBox):
-        def __init__(self, widget = None, varlist = None, vallist = None, icon = None, button = None, color = HobColors.LIGHT_GRAY):
+        def __init__(self, widget = None, varlist = None, vallist = None, icon = None, button = None, button2=None, color = HobColors.LIGHT_GRAY):
             gtk.EventBox.__init__(self)
 
             # set color
@@ -72,7 +72,11 @@ class ImageDetailsPage (HobPage):
                     self.table.attach(self.line_widgets[varlist[index]], colid, 20, row, row + 1)
             # pack the button on the right
             if button:
-                self.hbox.pack_end(button, expand=False, fill=False)
+                self.bbox = gtk.VBox()
+                self.bbox.pack_start(button, expand=True, fill=True)
+                if button2:
+                    self.bbox.pack_start(button2, expand=True, fill=True)
+                self.hbox.pack_end(self.bbox, expand=False, fill=False)
 
         def update_line_widgets(self, variable, value):
             if len(self.line_widgets) == 0:
@@ -164,8 +168,10 @@ class ImageDetailsPage (HobPage):
             base_image = self.builder.recipe_model.get_selected_image()
             layers = self.builder.configuration.layers
             pkg_num = "%s" % len(self.builder.package_model.get_selected_packages())
+            log_file = self.builder.current_logfile
         else:
             pkg_num = "N/A"
+            log_file = None
 
         # remove
         for button_id, button in self.button_ids.items():
@@ -243,11 +249,17 @@ class ImageDetailsPage (HobPage):
         view_files_button = HobAltButton("View files")
         view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr)
         view_files_button.set_tooltip_text("Open the directory containing the image files")
-        self.image_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=view_files_button)
+        view_log_button = None
+        if log_file:
+            view_log_button = HobAltButton("View log")
+            view_log_button.connect("clicked", self.view_log_clicked_cb, log_file)
+            view_log_button.set_tooltip_text("Open the building log files")
+        self.image_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=view_files_button, button2=view_log_button)
         self.box_group_area.pack_start(self.image_detail, expand=False, fill=True)
 
         # The default kernel box for the qemu images
         self.sel_kernel = ""
+        self.kernel_detail = None
         if 'qemu' in image_name:
             self.sel_kernel = self.get_kernel_file_name()
 
@@ -315,12 +327,16 @@ class ImageDetailsPage (HobPage):
             self.box_group_area.pack_start(self.details_bottom_buttons, expand=False, fill=False)
 
         self.show_all()
-        if not is_runnable:
+        if self.kernel_detail and (not is_runnable):
             self.kernel_detail.hide()
 
     def view_files_clicked_cb(self, button, image_addr):
         subprocess.call("xdg-open /%s" % image_addr, shell=True)
 
+    def view_log_clicked_cb(self, button, log_file):
+        if log_file:
+            os.system("xdg-open /%s" % log_file)
+
     def refresh_package_detail_box(self, image_size):
         self.package_detail.update_line_widgets("Total image size: ", image_size)
 
bitbake/lib/bb/ui/crumbs/packageselectionpage.py +23 -4
index 1b832eb..d101535 100755
@@ -143,8 +143,8 @@ class PackageSelectionPage (HobPage):
         # add all into the dialog
         self.box_group_area.pack_start(self.ins, expand=True, fill=True)
 
-        button_box = gtk.HBox(False, 6)
-        self.box_group_area.pack_start(button_box, expand=False, fill=False)
+        self.button_box = gtk.HBox(False, 6)
+        self.box_group_area.pack_start(self.button_box, expand=False, fill=False)
 
         self.build_image_button = HobButton('Build image')
         self.build_image_button.set_size_request(205, 49)
@@ -152,11 +152,11 @@ class PackageSelectionPage (HobPage):
         self.build_image_button.set_flags(gtk.CAN_DEFAULT)
         self.build_image_button.grab_default()
         self.build_image_button.connect("clicked", self.build_image_clicked_cb)
-        button_box.pack_end(self.build_image_button, expand=False, fill=False)
+        self.button_box.pack_end(self.build_image_button, expand=False, fill=False)
 
         self.back_button = HobAltButton("<< Back to image configuration")
         self.back_button.connect("clicked", self.back_button_clicked_cb)
-        button_box.pack_start(self.back_button, expand=False, fill=False)
+        self.button_box.pack_start(self.back_button, expand=False, fill=False)
 
     def button_click_cb(self, widget, event):
         path, col = widget.table_tree.get_cursor()
@@ -166,6 +166,25 @@ class PackageSelectionPage (HobPage):
             if binb:
                 self.builder.show_binb_dialog(binb)
 
+    def view_log_clicked_cb(self, button, log_file):
+        if log_file:
+            os.system("xdg-open /%s" % log_file)
+
+    def show_page(self, log_file):
+        children = self.button_box.get_children() or []
+        for child in children:
+            self.button_box.remove(child)
+        # re-packed the buttons as request, add the 'view log' button if build success
+        self.button_box.pack_start(self.back_button, expand=False, fill=False)
+        self.button_box.pack_end(self.build_image_button, expand=False, fill=False)
+        if log_file:
+            view_log_button = HobAltButton("View log")
+            view_log_button.connect("clicked", self.view_log_clicked_cb, log_file)
+            view_log_button.set_tooltip_text("Open the building log files")
+            self.button_box.pack_end(view_log_button, expand=False, fill=False)
+
+        self.show_all()
+
     def build_image_clicked_cb(self, button):
         self.builder.build_image()
 
bitbake/lib/bb/ui/crumbs/runningbuild.py +41 -0

84 lines not on this page · raw message

Signature · 1 line
1.7.5.4
author
#2 lore raw

PATCH 2/2 Hob: change the Build failure scenario as ui design

As ui design 'build-fail-spec.pdf' to change the GUI

[YOCTO #2183]

---
 bitbake/lib/bb/ui/crumbs/builddetailspage.py |   83 ++++++++++---------------
 1 files changed, 33 insertions(+), 50 deletions(-)
bitbake/lib/bb/ui/crumbs/builddetailspage.py +33 -50
index b1afe10..30eab29 100755
@@ -25,7 +25,7 @@ import pango
 import gobject
 import bb.process
 from bb.ui.crumbs.progressbar import HobProgressBar
-from bb.ui.crumbs.hobwidget import hic, HobNotebook, HobAltButton, HobWarpCellRendererText, HobButton
+from bb.ui.crumbs.hobwidget import hic, HobNotebook, HobAltButton, HobWarpCellRendererText, HobButton, HobInfoButton
 from bb.ui.crumbs.runningbuild import RunningBuildTreeView
 from bb.ui.crumbs.runningbuild import BuildFailureTreeView
 from bb.ui.crumbs.hobpages import HobPage
@@ -199,68 +199,51 @@ class BuildDetailsPage (HobPage):
         for child in children:
             self.remove(child)
 
-    def update_failures_sum_display(self):
-        num = 0
-        it = self.failure_model.get_iter_first()
-        while it:
-            color = self.failure_model.get_value(it, self.builder.handler.build.model.COL_COLOR)
-            if color == HobColors.ERROR:
-                num += 1
-            it = self.failure_model.iter_next(it)
-
-        return num
-
-    def add_build_fail_top_bar(self, actions):
-        mainly_action = "Edit %s" % actions
-        if 'image' in actions:
-            next_action   = ""
-        else:
-            next_action   = "Create new image"
+    def add_build_fail_top_bar(self, actions, log_file=None):
+        primary_action = "Edit %s" % actions
 
-        #set to issue page
         self.notebook.set_page("Issues")
 
         color = HobColors.ERROR
         build_fail_top = gtk.EventBox()
-        build_fail_top.set_size_request(-1, 260)
+        build_fail_top.set_size_request(-1, 200)
         build_fail_top.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
 
-        build_fail_tab = gtk.Table(7, 40, True)
+        build_fail_tab = gtk.Table(14, 46, True)
         build_fail_top.add(build_fail_tab)
 
         icon = gtk.Image()
         icon_pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_INDI_ERROR_FILE)
         icon.set_from_pixbuf(icon_pix_buffer)
-        build_fail_tab.attach(icon, 1, 4, 0, 3)
+        build_fail_tab.attach(icon, 1, 4, 0, 6)
 
         label = gtk.Label()
         label.set_alignment(0.0, 0.5)
-        label.set_markup("<span size='x-large'>%s</span>" % self.title)
-        build_fail_tab.attach(label, 4, 20, 0, 3)
+        label.set_markup("<span size='x-large'><b>%s</b></span>" % self.title)
+        build_fail_tab.attach(label, 4, 26, 0, 6)
 
         label = gtk.Label()
         label.set_alignment(0.0, 0.5)
-        num_of_fails = self.update_failures_sum_display()
-        current_fail, recipe_task_status = self.task_status.get_text().split('\n')
-        label.set_markup(" %d tasks failed,  %s, %s" % (num_of_fails, current_fail, recipe_task_status))
-        build_fail_tab.attach(label, 4, 40, 2, 4)
+        label.set_markup("<span size='medium'>Check the \"Issues\" information for more details</span>")
+        build_fail_tab.attach(label, 4, 40, 4, 9)
 
         # create button 'Edit packages'
-        action_button = HobButton(mainly_action)
-        action_button.set_size_request(-1, 49)
-        action_button.connect('clicked', self.failure_main_action_button_clicked_cb, mainly_action)
-        build_fail_tab.attach(action_button, 4, 16, 4, 6)
-
-        if next_action:
-            next_button = HobAltButton(next_action)
-            next_button.set_alignment(0.0, 0.5)
-            next_button.connect('clicked', self.failure_next_action_button_clicked_cb, next_action)
-            build_fail_tab.attach(next_button, 17, 24, 4, 5)
-
+        action_button = HobButton(primary_action)
+        action_button.set_size_request(-1, 40)
+        action_button.connect('clicked', self.failure_primary_action_button_clicked_cb, primary_action)
+        build_fail_tab.attach(action_button, 4, 13, 9, 12)
+
+        if log_file:
+            open_log_button = HobAltButton("Open log")
+            open_log_button.set_relief(gtk.RELIEF_HALF)
+            open_log_button.connect('clicked', self.failure_open_log_button_clicked_cb, log_file)
+            build_fail_tab.attach(open_log_button, 14, 23, 9, 12)
+
+        attach_pos = (24 if log_file else 14)
         file_bug_button = HobAltButton('File a bug')
-        file_bug_button.set_alignment(0.0, 0.5)
-        file_bug_button.connect('clicked', self.failure_file_bug_activate_link_cb)
-        build_fail_tab.attach(file_bug_button, 17, 24, 4 + abs(next_action != ""), 6)
+        file_bug_button.set_relief(gtk.RELIEF_HALF)
+        file_bug_button.connect('clicked', self.failure_activate_file_bug_link_cb)
+        build_fail_tab.attach(file_bug_button, attach_pos, attach_pos + 9, 9, 12)
 
         return build_fail_top
 
@@ -268,10 +251,10 @@ class BuildDetailsPage (HobPage):
         self._remove_all_widget()
         self.title = "Hob cannot build your %s" % title
 
-        self.build_fail_bar = self.add_build_fail_top_bar(action_names)
-        self.pack_start(self.build_fail_bar)
-        self.pack_start(self.group_align, expand=True, fill=True)
+        self.build_fail_bar = self.add_build_fail_top_bar(action_names, self.builder.current_logfile)
 
+        self.pack_start(self.group_align, expand=True, fill=True)
+        self.box_group_area.pack_start(self.build_fail_bar, expand=False, fill=False)
         self.box_group_area.pack_start(self.vbox, expand=True, fill=True)
 
         self.vbox.pack_start(self.notebook, expand=True, fill=True)
@@ -334,7 +317,7 @@ class BuildDetailsPage (HobPage):
     def show_configurations(self, configurations, params):
         self.config_tv.show(configurations, params)
 
-    def failure_main_action_button_clicked_cb(self, button, action):
+    def failure_primary_action_button_clicked_cb(self, button, action):
         if "Edit recipes" in action:
             self.builder.show_recipes()
         elif "Edit packages" in action:
@@ -342,9 +325,9 @@ class BuildDetailsPage (HobPage):
         elif "Edit image configuration" in action:
             self.builder.show_configuration()
 
-    def failure_next_action_button_clicked_cb(self, button, action):
-        if "Create new image" in action:
-            self.builder.initiate_new_build_async()
+    def failure_open_log_button_clicked_cb(self, button, log_file):
+        if log_file:
+            os.system("xdg-open /%s" % log_file)
 
-    def failure_file_bug_activate_link_cb(self, button):
+    def failure_activate_file_bug_link_cb(self, button):
         button.child.emit('activate-link', "http://bugzilla.yoctoproject.org")
Signature · 1 line
1.7.5.4