Patchwork [bitbake-devel,1/3] bitbake : handle each ui error

login
register
mail settings
Submitter Andrei Dinu
Date April 15, 2013, 10:38 a.m.
Message ID <1366022295-4744-2-git-send-email-andrei.adrianx.dinu@intel.com>
Download mbox | patch
Permalink /patch/48189/
State New
Headers show

Comments

Andrei Dinu - April 15, 2013, 10:38 a.m.
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.

Signed-off-by: Andrei Dinu <andrei.adrianx.dinu@intel.com>
---
 bitbake/bin/bitbake |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Patch

diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index 40b50e1..4dce7be 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -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)