From: Richard Purdie Date: Sat, 6 Dec 2008 13:03:19 +0000 (+0000) Subject: Update the UIs against the core changes and allow dynamic loading of the UI so UIs... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9f5dbcce6fd49383821d5f36fb88d35ddabc613f;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git Update the UIs against the core changes and allow dynamic loading of the UI so UIs become truly plugable. --- diff --git a/bin/bitbake b/bin/bitbake index 0a0ecfc4ee5..b699afbab7f 100755 --- a/bin/bitbake +++ b/bin/bitbake @@ -126,22 +126,6 @@ Default BBFILES are the .bb files in the current directory.""" ) configuration.pkgs_to_build = [] configuration.pkgs_to_build.extend(args[1:]) - - # Work out which UI(s) to use - curseUI = False - depexplorerUI = False - if configuration.ui: - if configuration.ui == "ncurses": - curseUI = True - elif configuration.ui == "knotty" or configuration.ui == "tty" or configuration.ui == "file": - curseUI = False - elif configuration.ui == "depexp": - depexplorerUI = True - else: - print "FATAL: Invalid user interface '%s' specified.\nValid interfaces are 'ncurses', 'depexp' or the default, 'knotty'." % configuration.ui - sys.exit(1) - - cooker = bb.cooker.BBCooker(configuration) # Clear away any spurious environment variables. But don't wipe the @@ -170,27 +154,22 @@ Default BBFILES are the .bb files in the current directory.""" ) eventHandler = uievent.BBUIEventQueue(server) # Launch the UI - try: - # Disable UIs that need a terminal - if not os.isatty(sys.stdout.fileno()): - curseUI = False - - if curseUI: - try: - import curses - except ImportError, details: - curseUI = False - - if curseUI: - from bb.ui import ncurses - ncurses.init(server, eventHandler) - elif depexplorerUI: - from bb.ui import depexplorer - depexplorer.init(server, eventHandler) - else: - from bb.ui import knotty - return_value = knotty.init(server, eventHandler) + if configuration.ui: + ui = configuration.ui + else: + ui = "knotty" + try: + # Dynamically load the UI based on the ui name. Although we + # suggest a fixed set this allows you to have flexibility in which + # ones are available. + exec "from bb.ui import " + ui + exec "return_value = " + ui + ".init(server, eventHandler)" + except ImportError: + print "FATAL: Invalid user interface '%s' specified. " % ui + print "Valid interfaces are 'ncurses', 'depexp' or the default, 'knotty'." + except Exception, e: + print "FATAL: Unable to start to '%s' UI: %s." % (configuration.ui, e.message) finally: # Don't wait for server indefinitely import socket diff --git a/lib/bb/ui/depexp.py b/lib/bb/ui/depexp.py index becbb5dd5da..9d92fa0a087 100644 --- a/lib/bb/ui/depexp.py +++ b/lib/bb/ui/depexp.py @@ -202,7 +202,7 @@ def init(server, eventHandler): if not cmdline or cmdline[0] != "generateDotGraph": print "This UI is only compatible with the -g option" return - ret = server.runCommand(["generateDepTreeEvent", cmdline[1]]) + ret = server.runCommand(["generateDepTreeEvent", cmdline[1], cmdline[2]]) if ret != True: print "Couldn't run command! %s" % ret return diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py index 0de90a92796..a6595df3f44 100644 --- a/lib/bb/ui/knotty.py +++ b/lib/bb/ui/knotty.py @@ -56,9 +56,6 @@ def init(server, eventHandler): if event is None: continue #print event - if event[0].startswith('bb.event.Pkg'): - print "NOTE: %s" % event[1]['_message'] - continue if event[0].startswith('bb.msg.MsgPlain'): print event[1]['_message'] continue @@ -75,12 +72,16 @@ def init(server, eventHandler): return_value = 1 print 'ERROR: ' + event[1]['_message'] continue + if event[0].startswith('bb.msg.MsgFatal'): + return_value = 1 + print 'FATAL: ' + event[1]['_message'] + break if event[0].startswith('bb.build.TaskFailed'): return_value = 1 logfile = event[1]['logfile'] if logfile: print "ERROR: Logfile of failure stored in %s." % logfile - if includelogs: + if 1 or includelogs: print "Log data follows:" f = open(logfile, "r") lines = [] @@ -140,6 +141,8 @@ def init(server, eventHandler): continue if event[0].startswith('bb.event.StampUpdate'): continue + if event[0].startswith('bb.event.ConfigParsed'): + continue print "Unknown Event: %s" % event except KeyboardInterrupt: diff --git a/lib/bb/ui/ncurses.py b/lib/bb/ui/ncurses.py index 1476baa61fa..3cac264648a 100644 --- a/lib/bb/ui/ncurses.py +++ b/lib/bb/ui/ncurses.py @@ -245,8 +245,6 @@ class NCursesUI: continue helper.eventHandler(event) #mw.appendText("%s\n" % event[0]) - if event[0].startswith('bb.event.Pkg'): - mw.appendText("NOTE: %s\n" % event[1]['_message']) if event[0].startswith('bb.build.Task'): mw.appendText("NOTE: %s\n" % event[1]['_message']) if event[0].startswith('bb.msg.MsgDebug'): @@ -324,6 +322,9 @@ class NCursesUI: pass def init(server, eventHandler): + if not os.isatty(sys.stdout.fileno()): + print "FATAL: Unable to run 'ncurses' UI without a TTY." + return ui = NCursesUI() try: curses.wrapper(ui.main, server, eventHandler)