Generic bitbake errors for hob ui
cover Generic bitbake errors for hob ui
Implemented a way to handle generic bitbake errors when starting a ui ( in this case hob ).
[HOB #3909]
Andrei Dinu (3):
bitbake : handle each ui error
hob.py : implemented handle_sys_exit() for hob
hoberror.py : new class in handling hob errors
bitbake/bin/bitbake | 13 +++-- bitbake/lib/bb/ui/crumbs/hig/hoberror.py | 87 ++++++++++++++++++++++++++++++ bitbake/lib/bb/ui/hob.py | 8 ++- 3 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 bitbake/lib/bb/ui/crumbs/hig/hoberror.py
Signature · 1 line
1.7.9.5
PATCH 1/3 bitbake : handle each ui error
Added the functionality to bitbake to handle each ui error in particular. The function handle_sys_exit() needs to be implemented in the ui that needs different error reporting than default.
--- bitbake/bin/bitbake | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
bitbake/bin/bitbake +10 -3
@@ -75,7 +75,7 @@ def get_ui(config): # suggest a fixed set this allows you to have flexibility in which # ones are available. module = __import__("bb.ui", fromlist = [interface]) - return getattr(module, interface).main + return getattr(module, interface) except AttributeError: sys.exit("FATAL: Invalid user interface '%s' specified.\n" "Valid interfaces: depexp, goggle, ncurses, hob, knotty [default]." % interface)
@@ -100,7 +100,7 @@ warnings.filterwarnings("ignore", category=ImportWarning) warnings.filterwarnings("ignore", category=DeprecationWarning, module="<string>$") warnings.filterwarnings("ignore", message="With-statements now directly support multiple context managers") - +ui_main = None def main(): parser = optparse.OptionParser( version = "BitBake Build Tool Core version %s, %%prog version %s" % (bb.__version__, __version__),
@@ -189,6 +189,7 @@ Default BBFILES are the .bb files in the current directory.""") configuration = BBConfiguration(options) configuration.pkgs_to_build.extend(args[1:]) + global ui_main ui_main = get_ui(configuration) # Server type can be xmlrpc, process or none currently, if nothing is specified,
@@ -261,7 +262,7 @@ Default BBFILES are the .bb files in the current directory.""") os.environ[k] = cleanedvars[k] try: - return server.launchUI(ui_main, server_connection.connection, server_connection.events) + return server.launchUI(ui_main.main, server_connection.connection, server_connection.events) finally: bb.event.ui_queue = [] server_connection.terminate()
@@ -277,5 +278,11 @@ if __name__ == "__main__": ret = 1 import traceback traceback.print_exc(5) + except SystemExit: + try: + hasattr(ui_main, 'handle_sys_exit') + ui_main.handle_sys_exit() + except AttributeError: + ret = 1 sys.exit(ret)
Signature · 1 line
1.7.9.5
PATCH 2/3 hob.py : implemented handle_sys_exit() for hob
In reply to Andrei DinuIn order to display the error shown by bitbake in a dialog rather than in the console, handle_sys_exit() was implemented in hob ui.
--- bitbake/lib/bb/ui/hob.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
bitbake/lib/bb/ui/hob.py +6 -2
@@ -11,8 +11,6 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. #
@@ -22,6 +20,7 @@ import sys import os +from bb.ui.crumbs.hig import hoberror requirements = "FATAL: Hob requires Gtk+ 2.20.0 or higher, PyGtk 2.21.0 or higher" try: import gobject
@@ -83,6 +82,11 @@ def main (server = None, eventHandler = None): finally: hobHandler.cancel_build(force = True) +def handle_sys_exit(): + dialog = hoberror.HobError(bb.event.ui_queue[len(bb.event.ui_queue)-1].getMessage()) + bb.event.ui_queue = [] + dialog.run() + if __name__ == "__main__": try: ret = main()
Signature · 1 line
1.7.9.5
PATCH 3/3 hoberror.py : new class in handling hob errors
In reply to Andrei DinuWhen an error is present in starting hob, it is
displayed in an dialog, forcing you to close hob.
--- bitbake/lib/bb/ui/crumbs/hig/hoberror.py | 87 ++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 bitbake/lib/bb/ui/crumbs/hig/hoberror.py
bitbake/lib/bb/ui/crumbs/hig/hoberror.py new file +87 -0
@@ -0,0 +1,87 @@ +# +# BitBake Graphical GTK User Interface +# +# Copyright (C) 2011-2013 Intel Corporation +# +# Authored by Andrei Dinu <[email protected]> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import pygtk +import gtk +import sys +import os +from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog +from bb.ui.crumbs.hig.settingsuihelper import SettingsUIHelper +from bb.ui.crumbs.hig.crumbsmessagedialog import CrumbsMessageDialog +from bb.ui.crumbs.hig.layerselectiondialog import LayerSelectionDialog + +class HobError(): + + def __init__(self,message): + + self.message = message + + self.create_visual_elements() + + def run(self): + + self.dialog.run() + + def create_visual_elements(self): + + icon_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), ("icons/")) + icon_file = os.path.join(icon_dir, ('indicators/denied.png')) + + self.dialog = gtk.Dialog("Hob - Image creator", + None, + gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) + + self.dialog.set_size_request(600,400) + self.dialog.set_resizable(True) + + table = gtk.Table(3,1,False) + table.set_row_spacings(0) + table.set_col_spacings(0) + + image = gtk.Image() + image.set_from_file(icon_file) + image.set_property("xalign",0) + + label_short = gtk.Label() + label_short.set_line_wrap(False) + label_short.set_markup("<span size='19000'>" + 'Hob found an error' + "</span>") + label_short.set_property("xalign", 0) + + info_label = gtk.Label() + info_label.set_line_wrap(True) + info_label.set_selectable(True) + info_label.set_markup(self.message) + info_label.set_property("xalign",0) + + close_button = gtk.Button("Close Hob") + close_button.connect("clicked", lambda w:sys.exit()) + + table.attach(image, 0,1,0,1, xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.EXPAND,xpadding=20,ypadding=20) + table.attach(label_short, 0,1,0,1, xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.SHRINK,xpadding=80,ypadding=20) + table.attach(info_label, 0,1,1,2, xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.EXPAND,xpadding=80,ypadding=0) + + alignment = gtk.Alignment() + alignment.add(close_button) + table.attach(alignment, 0,1,2,3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=gtk.EXPAND,xpadding=75,ypadding=30) + + self.dialog.vbox.pack_start(table, expand=False, fill=False) + self.dialog.vbox.show_all() + + self.dialog.connect("delete-event", gtk.main_quit)
Signature · 1 line
1.7.9.5