diff options
Diffstat (limited to 'bitbake-dev/lib/bb/ui')
| -rw-r--r-- | bitbake-dev/lib/bb/ui/__init__.py | 18 | ||||
| -rw-r--r-- | bitbake-dev/lib/bb/ui/depexplorer.py | 271 | ||||
| -rw-r--r-- | bitbake-dev/lib/bb/ui/knotty.py | 157 | ||||
| -rw-r--r-- | bitbake-dev/lib/bb/ui/ncurses.py | 333 | ||||
| -rw-r--r-- | bitbake-dev/lib/bb/ui/uievent.py | 127 | ||||
| -rw-r--r-- | bitbake-dev/lib/bb/ui/uihelper.py | 49 |
6 files changed, 955 insertions, 0 deletions
diff --git a/bitbake-dev/lib/bb/ui/__init__.py b/bitbake-dev/lib/bb/ui/__init__.py new file mode 100644 index 0000000000..c6a377a8e6 --- /dev/null +++ b/bitbake-dev/lib/bb/ui/__init__.py | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | # | ||
| 2 | # BitBake UI Implementation | ||
| 3 | # | ||
| 4 | # Copyright (C) 2006-2007 Richard Purdie | ||
| 5 | # | ||
| 6 | # This program is free software; you can redistribute it and/or modify | ||
| 7 | # it under the terms of the GNU General Public License version 2 as | ||
| 8 | # published by the Free Software Foundation. | ||
| 9 | # | ||
| 10 | # This program is distributed in the hope that it will be useful, | ||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | # GNU General Public License for more details. | ||
| 14 | # | ||
| 15 | # You should have received a copy of the GNU General Public License along | ||
| 16 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 18 | |||
diff --git a/bitbake-dev/lib/bb/ui/depexplorer.py b/bitbake-dev/lib/bb/ui/depexplorer.py new file mode 100644 index 0000000000..becbb5dd5d --- /dev/null +++ b/bitbake-dev/lib/bb/ui/depexplorer.py | |||
| @@ -0,0 +1,271 @@ | |||
| 1 | # | ||
| 2 | # BitBake Graphical GTK based Dependency Explorer | ||
| 3 | # | ||
| 4 | # Copyright (C) 2007 Ross Burton | ||
| 5 | # Copyright (C) 2007 - 2008 Richard Purdie | ||
| 6 | # | ||
| 7 | # This program is free software; you can redistribute it and/or modify | ||
| 8 | # it under the terms of the GNU General Public License version 2 as | ||
| 9 | # published by the Free Software Foundation. | ||
| 10 | # | ||
| 11 | # This program is distributed in the hope that it will be useful, | ||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | # GNU General Public License for more details. | ||
| 15 | # | ||
| 16 | # You should have received a copy of the GNU General Public License along | ||
| 17 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 19 | |||
| 20 | import gobject | ||
| 21 | import gtk | ||
| 22 | import threading | ||
| 23 | |||
| 24 | # Package Model | ||
| 25 | (COL_PKG_NAME) = (0) | ||
| 26 | |||
| 27 | # Dependency Model | ||
| 28 | (TYPE_DEP, TYPE_RDEP) = (0, 1) | ||
| 29 | (COL_DEP_TYPE, COL_DEP_PARENT, COL_DEP_PACKAGE) = (0, 1, 2) | ||
| 30 | |||
| 31 | class PackageDepView(gtk.TreeView): | ||
| 32 | def __init__(self, model, dep_type, label): | ||
| 33 | gtk.TreeView.__init__(self) | ||
| 34 | self.current = None | ||
| 35 | self.dep_type = dep_type | ||
| 36 | self.filter_model = model.filter_new() | ||
| 37 | self.filter_model.set_visible_func(self._filter) | ||
| 38 | self.set_model(self.filter_model) | ||
| 39 | #self.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) | ||
| 40 | self.append_column(gtk.TreeViewColumn(label, gtk.CellRendererText(), text=COL_DEP_PACKAGE)) | ||
| 41 | |||
| 42 | def _filter(self, model, iter): | ||
| 43 | (this_type, package) = model.get(iter, COL_DEP_TYPE, COL_DEP_PARENT) | ||
| 44 | if this_type != self.dep_type: return False | ||
| 45 | return package == self.current | ||
| 46 | |||
| 47 | def set_current_package(self, package): | ||
| 48 | self.current = package | ||
| 49 | self.filter_model.refilter() | ||
| 50 | |||
| 51 | class PackageReverseDepView(gtk.TreeView): | ||
| 52 | def __init__(self, model, label): | ||
| 53 | gtk.TreeView.__init__(self) | ||
| 54 | self.current = None | ||
| 55 | self.filter_model = model.filter_new() | ||
| 56 | self.filter_model.set_visible_func(self._filter) | ||
| 57 | self.set_model(self.filter_model) | ||
| 58 | self.append_column(gtk.TreeViewColumn(label, gtk.CellRendererText(), text=COL_DEP_PARENT)) | ||
| 59 | |||
| 60 | def _filter(self, model, iter): | ||
| 61 | package = model.get_value(iter, COL_DEP_PACKAGE) | ||
| 62 | return package == self.current | ||
| 63 | |||
| 64 | def set_current_package(self, package): | ||
| 65 | self.current = package | ||
| 66 | self.filter_model.refilter() | ||
| 67 | |||
| 68 | class DepExplorer(gtk.Window): | ||
| 69 | def __init__(self): | ||
| 70 | gtk.Window.__init__(self) | ||
| 71 | self.set_title("Dependency Explorer") | ||
| 72 | self.set_default_size(500, 500) | ||
| 73 | self.connect("delete-event", gtk.main_quit) | ||
| 74 | |||
| 75 | # Create the data models | ||
| 76 | self.pkg_model = gtk.ListStore(gobject.TYPE_STRING) | ||
| 77 | self.depends_model = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING) | ||
| 78 | |||
| 79 | pane = gtk.HPaned() | ||
| 80 | pane.set_position(250) | ||
| 81 | self.add(pane) | ||
| 82 | |||
| 83 | # The master list of packages | ||
| 84 | scrolled = gtk.ScrolledWindow() | ||
| 85 | scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) | ||
| 86 | scrolled.set_shadow_type(gtk.SHADOW_IN) | ||
| 87 | self.pkg_treeview = gtk.TreeView(self.pkg_model) | ||
| 88 | self.pkg_treeview.get_selection().connect("changed", self.on_cursor_changed) | ||
| 89 | self.pkg_treeview.append_column(gtk.TreeViewColumn("Package", gtk.CellRendererText(), text=COL_PKG_NAME)) | ||
| 90 | pane.add1(scrolled) | ||
| 91 | scrolled.add(self.pkg_treeview) | ||
| 92 | |||
| 93 | box = gtk.VBox(homogeneous=True, spacing=4) | ||
| 94 | |||
| 95 | # Runtime Depends | ||
| 96 | scrolled = gtk.ScrolledWindow() | ||
| 97 | scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) | ||
| 98 | scrolled.set_shadow_type(gtk.SHADOW_IN) | ||
| 99 | self.rdep_treeview = PackageDepView(self.depends_model, TYPE_RDEP, "Runtime Depends") | ||
| 100 | self.rdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) | ||
| 101 | scrolled.add(self.rdep_treeview) | ||
| 102 | box.add(scrolled) | ||
| 103 | |||
| 104 | # Build Depends | ||
| 105 | scrolled = gtk.ScrolledWindow() | ||
| 106 | scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) | ||
| 107 | scrolled.set_shadow_type(gtk.SHADOW_IN) | ||
| 108 | self.dep_treeview = PackageDepView(self.depends_model, TYPE_DEP, "Build Depends") | ||
| 109 | self.dep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) | ||
| 110 | scrolled.add(self.dep_treeview) | ||
| 111 | box.add(scrolled) | ||
| 112 | pane.add2(box) | ||
| 113 | |||
| 114 | # Reverse Depends | ||
| 115 | scrolled = gtk.ScrolledWindow() | ||
| 116 | scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) | ||
| 117 | scrolled.set_shadow_type(gtk.SHADOW_IN) | ||
| 118 | self.revdep_treeview = PackageReverseDepView(self.depends_model, "Reverse Depends") | ||
| 119 | self.revdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PARENT) | ||
| 120 | scrolled.add(self.revdep_treeview) | ||
| 121 | box.add(scrolled) | ||
| 122 | pane.add2(box) | ||
| 123 | |||
| 124 | self.show_all() | ||
| 125 | |||
| 126 | def on_package_activated(self, treeview, path, column, data_col): | ||
| 127 | model = treeview.get_model() | ||
| 128 | package = model.get_value(model.get_iter(path), data_col) | ||
| 129 | |||
| 130 | pkg_path = [] | ||
| 131 | def finder(model, path, iter, needle): | ||
| 132 | package = model.get_value(iter, COL_PKG_NAME) | ||
| 133 | if package == needle: | ||
| 134 | pkg_path.append(path) | ||
| 135 | return True | ||
| 136 | else: | ||
| 137 | return False | ||
| 138 | self.pkg_model.foreach(finder, package) | ||
| 139 | if pkg_path: | ||
| 140 | self.pkg_treeview.get_selection().select_path(pkg_path[0]) | ||
| 141 | self.pkg_treeview.scroll_to_cell(pkg_path[0]) | ||
| 142 | |||
| 143 | def on_cursor_changed(self, selection): | ||
| 144 | (model, it) = selection.get_selected() | ||
| 145 | if iter is None: | ||
| 146 | current_package = None | ||
| 147 | else: | ||
| 148 | current_package = model.get_value(it, COL_PKG_NAME) | ||
| 149 | self.rdep_treeview.set_current_package(current_package) | ||
| 150 | self.dep_treeview.set_current_package(current_package) | ||
| 151 | self.revdep_treeview.set_current_package(current_package) | ||
| 152 | |||
| 153 | |||
| 154 | def parse(depgraph, pkg_model, depends_model): | ||
| 155 | |||
| 156 | for package in depgraph["pn"]: | ||
| 157 | pkg_model.set(pkg_model.append(), COL_PKG_NAME, package) | ||
| 158 | |||
| 159 | for package in depgraph["depends"]: | ||
| 160 | for depend in depgraph["depends"][package]: | ||
| 161 | depends_model.set (depends_model.append(), | ||
| 162 | COL_DEP_TYPE, TYPE_DEP, | ||
| 163 | COL_DEP_PARENT, package, | ||
| 164 | COL_DEP_PACKAGE, depend) | ||
| 165 | |||
| 166 | for package in depgraph["rdepends-pn"]: | ||
| 167 | for rdepend in depgraph["rdepends-pn"][package]: | ||
| 168 | depends_model.set (depends_model.append(), | ||
| 169 | COL_DEP_TYPE, TYPE_RDEP, | ||
| 170 | COL_DEP_PARENT, package, | ||
| 171 | COL_DEP_PACKAGE, rdepend) | ||
| 172 | |||
| 173 | class ProgressBar(gtk.Window): | ||
| 174 | def __init__(self): | ||
| 175 | |||
| 176 | gtk.Window.__init__(self) | ||
| 177 | self.set_title("Parsing .bb files, please wait...") | ||
| 178 | self.set_default_size(500, 0) | ||
| 179 | self.connect("delete-event", gtk.main_quit) | ||
| 180 | |||
| 181 | self.progress = gtk.ProgressBar() | ||
| 182 | self.add(self.progress) | ||
| 183 | self.show_all() | ||
| 184 | |||
| 185 | class gtkthread(threading.Thread): | ||
| 186 | quit = threading.Event() | ||
| 187 | def __init__(self, shutdown): | ||
| 188 | threading.Thread.__init__(self) | ||
| 189 | self.setDaemon(True) | ||
| 190 | self.shutdown = shutdown | ||
| 191 | |||
| 192 | def run(self): | ||
| 193 | gobject.threads_init() | ||
| 194 | gtk.gdk.threads_init() | ||
| 195 | gtk.main() | ||
| 196 | gtkthread.quit.set() | ||
| 197 | |||
| 198 | def init(server, eventHandler): | ||
| 199 | |||
| 200 | try: | ||
| 201 | cmdline = server.runCommand(["getCmdLineAction"]) | ||
| 202 | if not cmdline or cmdline[0] != "generateDotGraph": | ||
| 203 | print "This UI is only compatible with the -g option" | ||
| 204 | return | ||
| 205 | ret = server.runCommand(["generateDepTreeEvent", cmdline[1]]) | ||
| 206 | if ret != True: | ||
| 207 | print "Couldn't run command! %s" % ret | ||
| 208 | return | ||
| 209 | except xmlrpclib.Fault, x: | ||
| 210 | print "XMLRPC Fault getting commandline:\n %s" % x | ||
| 211 | return | ||
| 212 | |||
| 213 | shutdown = 0 | ||
| 214 | |||
| 215 | gtkgui = gtkthread(shutdown) | ||
| 216 | gtkgui.start() | ||
| 217 | |||
| 218 | gtk.gdk.threads_enter() | ||
| 219 | pbar = ProgressBar() | ||
| 220 | dep = DepExplorer() | ||
| 221 | gtk.gdk.threads_leave() | ||
| 222 | |||
| 223 | while True: | ||
| 224 | try: | ||
| 225 | event = eventHandler.waitEvent(0.25) | ||
| 226 | if gtkthread.quit.isSet(): | ||
| 227 | break | ||
| 228 | |||
| 229 | if event is None: | ||
| 230 | continue | ||
| 231 | if event[0].startswith('bb.event.ParseProgress'): | ||
| 232 | x = event[1]['sofar'] | ||
| 233 | y = event[1]['total'] | ||
| 234 | if x == y: | ||
| 235 | print("\nParsing finished. %d cached, %d parsed, %d skipped, %d masked, %d errors." | ||
| 236 | % ( event[1]['cached'], event[1]['parsed'], event[1]['skipped'], event[1]['masked'], event[1]['errors'])) | ||
| 237 | pbar.hide() | ||
| 238 | gtk.gdk.threads_enter() | ||
| 239 | pbar.progress.set_fraction(float(x)/float(y)) | ||
| 240 | pbar.progress.set_text("%d/%d (%2d %%)" % (x, y, x*100/y)) | ||
| 241 | gtk.gdk.threads_leave() | ||
| 242 | continue | ||
| 243 | |||
| 244 | if event[0] == "bb.event.DepTreeGenerated": | ||
| 245 | gtk.gdk.threads_enter() | ||
| 246 | parse(event[1]['_depgraph'], dep.pkg_model, dep.depends_model) | ||
| 247 | gtk.gdk.threads_leave() | ||
| 248 | |||
| 249 | if event[0] == 'bb.command.CookerCommandCompleted': | ||
| 250 | continue | ||
| 251 | if event[0] == 'bb.command.CookerCommandFailed': | ||
| 252 | print "Command execution failed: %s" % event[1]['error'] | ||
| 253 | break | ||
| 254 | if event[0] == 'bb.cooker.CookerExit': | ||
| 255 | break | ||
| 256 | |||
| 257 | continue | ||
| 258 | |||
| 259 | except KeyboardInterrupt: | ||
| 260 | if shutdown == 2: | ||
| 261 | print "\nThird Keyboard Interrupt, exit.\n" | ||
| 262 | break | ||
| 263 | if shutdown == 1: | ||
| 264 | print "\nSecond Keyboard Interrupt, stopping...\n" | ||
| 265 | server.runCommand(["stateStop"]) | ||
| 266 | if shutdown == 0: | ||
| 267 | print "\nKeyboard Interrupt, closing down...\n" | ||
| 268 | server.runCommand(["stateShutdown"]) | ||
| 269 | shutdown = shutdown + 1 | ||
| 270 | pass | ||
| 271 | |||
diff --git a/bitbake-dev/lib/bb/ui/knotty.py b/bitbake-dev/lib/bb/ui/knotty.py new file mode 100644 index 0000000000..9e89660307 --- /dev/null +++ b/bitbake-dev/lib/bb/ui/knotty.py | |||
| @@ -0,0 +1,157 @@ | |||
| 1 | # | ||
| 2 | # BitBake (No)TTY UI Implementation | ||
| 3 | # | ||
| 4 | # Handling output to TTYs or files (no TTY) | ||
| 5 | # | ||
| 6 | # Copyright (C) 2006-2007 Richard Purdie | ||
| 7 | # | ||
| 8 | # This program is free software; you can redistribute it and/or modify | ||
| 9 | # it under the terms of the GNU General Public License version 2 as | ||
| 10 | # published by the Free Software Foundation. | ||
| 11 | # | ||
| 12 | # This program is distributed in the hope that it will be useful, | ||
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | # GNU General Public License for more details. | ||
| 16 | # | ||
| 17 | # You should have received a copy of the GNU General Public License along | ||
| 18 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 20 | |||
| 21 | import os | ||
| 22 | import bb | ||
| 23 | from bb import cooker | ||
| 24 | |||
| 25 | import sys | ||
| 26 | import time | ||
| 27 | import itertools | ||
| 28 | import xmlrpclib | ||
| 29 | |||
| 30 | parsespin = itertools.cycle( r'|/-\\' ) | ||
| 31 | |||
| 32 | def init(server, eventHandler): | ||
| 33 | |||
| 34 | # Get values of variables which control our output | ||
| 35 | includelogs = server.runCommand(["readVariable", "BBINCLUDELOGS"]) | ||
| 36 | loglines = server.runCommand(["readVariable", "BBINCLUDELOGS_LINES"]) | ||
| 37 | |||
| 38 | try: | ||
| 39 | cmdline = server.runCommand(["getCmdLineAction"]) | ||
| 40 | #print cmdline | ||
| 41 | if not cmdline: | ||
| 42 | return 1 | ||
| 43 | ret = server.runCommand(cmdline) | ||
| 44 | if ret != True: | ||
| 45 | print "Couldn't get default commandline! %s" % ret | ||
| 46 | return 1 | ||
| 47 | except xmlrpclib.Fault, x: | ||
| 48 | print "XMLRPC Fault getting commandline:\n %s" % x | ||
| 49 | return 1 | ||
| 50 | |||
| 51 | shutdown = 0 | ||
| 52 | return_value = 0 | ||
| 53 | while True: | ||
| 54 | try: | ||
| 55 | event = eventHandler.waitEvent(0.25) | ||
| 56 | if event is None: | ||
| 57 | continue | ||
| 58 | #print event | ||
| 59 | if event[0].startswith('bb.event.Pkg'): | ||
| 60 | print "NOTE: %s" % event[1]['_message'] | ||
| 61 | continue | ||
| 62 | if event[0].startswith('bb.msg.MsgPlain'): | ||
| 63 | print event[1]['_message'] | ||
| 64 | continue | ||
| 65 | if event[0].startswith('bb.msg.MsgDebug'): | ||
| 66 | print 'DEBUG: ' + event[1]['_message'] | ||
| 67 | continue | ||
| 68 | if event[0].startswith('bb.msg.MsgNote'): | ||
| 69 | print 'NOTE: ' + event[1]['_message'] | ||
| 70 | continue | ||
| 71 | if event[0].startswith('bb.msg.MsgWarn'): | ||
| 72 | print 'WARNING: ' + event[1]['_message'] | ||
| 73 | continue | ||
| 74 | if event[0].startswith('bb.msg.MsgError'): | ||
| 75 | return_value = 1 | ||
| 76 | print 'ERROR: ' + event[1]['_message'] | ||
| 77 | continue | ||
| 78 | if event[0].startswith('bb.build.TaskFailed'): | ||
| 79 | return_value = 1 | ||
| 80 | logfile = event[1]['logfile'] | ||
| 81 | if logfile: | ||
| 82 | print "ERROR: Logfile of failure stored in %s." % logfile | ||
| 83 | if includelogs: | ||
| 84 | print "Log data follows:" | ||
| 85 | f = open(logfile, "r") | ||
| 86 | lines = [] | ||
| 87 | while True: | ||
| 88 | l = f.readline() | ||
| 89 | if l == '': | ||
| 90 | break | ||
| 91 | l = l.rstrip() | ||
| 92 | if loglines: | ||
| 93 | lines.append(' | %s' % l) | ||
| 94 | if len(lines) > int(loglines): | ||
| 95 | lines.pop(0) | ||
| 96 | else: | ||
| 97 | print '| %s' % l | ||
| 98 | f.close() | ||
| 99 | if lines: | ||
| 100 | for line in lines: | ||
| 101 | print line | ||
| 102 | if event[0].startswith('bb.build.Task'): | ||
| 103 | print "NOTE: %s" % event[1]['_message'] | ||
| 104 | continue | ||
| 105 | if event[0].startswith('bb.event.ParseProgress'): | ||
| 106 | x = event[1]['sofar'] | ||
| 107 | y = event[1]['total'] | ||
| 108 | if os.isatty(sys.stdout.fileno()): | ||
| 109 | sys.stdout.write("\rNOTE: Handling BitBake files: %s (%04d/%04d) [%2d %%]" % ( parsespin.next(), x, y, x*100/y ) ) | ||
| 110 | sys.stdout.flush() | ||
| 111 | else: | ||
| 112 | if x == 1: | ||
| 113 | sys.stdout.write("Parsing .bb files, please wait...") | ||
| 114 | sys.stdout.flush() | ||
| 115 | if x == y: | ||
| 116 | sys.stdout.write("done.") | ||
| 117 | sys.stdout.flush() | ||
| 118 | if x == y: | ||
| 119 | print("\nParsing finished. %d cached, %d parsed, %d skipped, %d masked, %d errors." | ||
| 120 | % ( event[1]['cached'], event[1]['parsed'], event[1]['skipped'], event[1]['masked'], event[1]['errors'])) | ||
| 121 | continue | ||
| 122 | |||
| 123 | if event[0] == 'bb.command.CookerCommandCompleted': | ||
| 124 | break | ||
| 125 | if event[0] == 'bb.command.CookerCommandFailed': | ||
| 126 | return_value = 1 | ||
| 127 | print "Command execution failed: %s" % event[1]['error'] | ||
| 128 | break | ||
| 129 | if event[0] == 'bb.cooker.CookerExit': | ||
| 130 | break | ||
| 131 | |||
| 132 | # ignore | ||
| 133 | if event[0].startswith('bb.event.BuildStarted'): | ||
| 134 | continue | ||
| 135 | if event[0].startswith('bb.event.BuildCompleted'): | ||
| 136 | continue | ||
| 137 | if event[0].startswith('bb.event.MultipleProviders'): | ||
| 138 | continue | ||
| 139 | if event[0].startswith('bb.runqueue.runQueue'): | ||
| 140 | continue | ||
| 141 | if event[0].startswith('bb.event.StampUpdate'): | ||
| 142 | continue | ||
| 143 | print "Unknown Event: %s" % event | ||
| 144 | |||
| 145 | except KeyboardInterrupt: | ||
| 146 | if shutdown == 2: | ||
| 147 | print "\nThird Keyboard Interrupt, exit.\n" | ||
| 148 | break | ||
| 149 | if shutdown == 1: | ||
| 150 | print "\nSecond Keyboard Interrupt, stopping...\n" | ||
| 151 | server.runCommand(["stateStop"]) | ||
| 152 | if shutdown == 0: | ||
| 153 | print "\nKeyboard Interrupt, closing down...\n" | ||
| 154 | server.runCommand(["stateShutdown"]) | ||
| 155 | shutdown = shutdown + 1 | ||
| 156 | pass | ||
| 157 | return return_value | ||
diff --git a/bitbake-dev/lib/bb/ui/ncurses.py b/bitbake-dev/lib/bb/ui/ncurses.py new file mode 100644 index 0000000000..1476baa61f --- /dev/null +++ b/bitbake-dev/lib/bb/ui/ncurses.py | |||
| @@ -0,0 +1,333 @@ | |||
| 1 | # | ||
| 2 | # BitBake Curses UI Implementation | ||
| 3 | # | ||
| 4 | # Implements an ncurses frontend for the BitBake utility. | ||
| 5 | # | ||
| 6 | # Copyright (C) 2006 Michael 'Mickey' Lauer | ||
| 7 | # Copyright (C) 2006-2007 Richard Purdie | ||
| 8 | # | ||
| 9 | # This program is free software; you can redistribute it and/or modify | ||
| 10 | # it under the terms of the GNU General Public License version 2 as | ||
| 11 | # published by the Free Software Foundation. | ||
| 12 | # | ||
| 13 | # This program is distributed in the hope that it will be useful, | ||
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | # GNU General Public License for more details. | ||
| 17 | # | ||
| 18 | # You should have received a copy of the GNU General Public License along | ||
| 19 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 21 | |||
| 22 | """ | ||
| 23 | We have the following windows: | ||
| 24 | |||
| 25 | 1.) Main Window: Shows what we are ultimately building and how far we are. Includes status bar | ||
| 26 | 2.) Thread Activity Window: Shows one status line for every concurrent bitbake thread. | ||
| 27 | 3.) Command Line Window: Contains an interactive command line where you can interact w/ Bitbake. | ||
| 28 | |||
| 29 | Basic window layout is like that: | ||
| 30 | |||
| 31 | |---------------------------------------------------------| | ||
| 32 | | <Main Window> | <Thread Activity Window> | | ||
| 33 | | | 0: foo do_compile complete| | ||
| 34 | | Building Gtk+-2.6.10 | 1: bar do_patch complete | | ||
| 35 | | Status: 60% | ... | | ||
| 36 | | | ... | | ||
| 37 | | | ... | | ||
| 38 | |---------------------------------------------------------| | ||
| 39 | |<Command Line Window> | | ||
| 40 | |>>> which virtual/kernel | | ||
| 41 | |openzaurus-kernel | | ||
| 42 | |>>> _ | | ||
| 43 | |---------------------------------------------------------| | ||
| 44 | |||
| 45 | """ | ||
| 46 | |||
| 47 | import os, sys, curses, time, random, threading, itertools, time | ||
| 48 | from curses.textpad import Textbox | ||
| 49 | import bb | ||
| 50 | from bb import ui | ||
| 51 | from bb.ui import uihelper | ||
| 52 | |||
| 53 | parsespin = itertools.cycle( r'|/-\\' ) | ||
| 54 | |||
| 55 | X = 0 | ||
| 56 | Y = 1 | ||
| 57 | WIDTH = 2 | ||
| 58 | HEIGHT = 3 | ||
| 59 | |||
| 60 | MAXSTATUSLENGTH = 32 | ||
| 61 | |||
| 62 | class NCursesUI: | ||
| 63 | """ | ||
| 64 | NCurses UI Class | ||
| 65 | """ | ||
| 66 | class Window: | ||
| 67 | """Base Window Class""" | ||
| 68 | def __init__( self, x, y, width, height, fg=curses.COLOR_BLACK, bg=curses.COLOR_WHITE ): | ||
| 69 | self.win = curses.newwin( height, width, y, x ) | ||
| 70 | self.dimensions = ( x, y, width, height ) | ||
| 71 | """ | ||
| 72 | if curses.has_colors(): | ||
| 73 | color = 1 | ||
| 74 | curses.init_pair( color, fg, bg ) | ||
| 75 | self.win.bkgdset( ord(' '), curses.color_pair(color) ) | ||
| 76 | else: | ||
| 77 | self.win.bkgdset( ord(' '), curses.A_BOLD ) | ||
| 78 | """ | ||
| 79 | self.erase() | ||
| 80 | self.setScrolling() | ||
| 81 | self.win.noutrefresh() | ||
| 82 | |||
| 83 | def erase( self ): | ||
| 84 | self.win.erase() | ||
| 85 | |||
| 86 | def setScrolling( self, b = True ): | ||
| 87 | self.win.scrollok( b ) | ||
| 88 | self.win.idlok( b ) | ||
| 89 | |||
| 90 | def setBoxed( self ): | ||
| 91 | self.boxed = True | ||
| 92 | self.win.box() | ||
| 93 | self.win.noutrefresh() | ||
| 94 | |||
| 95 | def setText( self, x, y, text, *args ): | ||
| 96 | self.win.addstr( y, x, text, *args ) | ||
| 97 | self.win.noutrefresh() | ||
| 98 | |||
| 99 | def appendText( self, text, *args ): | ||
| 100 | self.win.addstr( text, *args ) | ||
| 101 | self.win.noutrefresh() | ||
| 102 | |||
| 103 | def drawHline( self, y ): | ||
| 104 | self.win.hline( y, 0, curses.ACS_HLINE, self.dimensions[WIDTH] ) | ||
| 105 | self.win.noutrefresh() | ||
| 106 | |||
| 107 | class DecoratedWindow( Window ): | ||
| 108 | """Base class for windows with a box and a title bar""" | ||
| 109 | def __init__( self, title, x, y, width, height, fg=curses.COLOR_BLACK, bg=curses.COLOR_WHITE ): | ||
| 110 | NCursesUI.Window.__init__( self, x+1, y+3, width-2, height-4, fg, bg ) | ||
| 111 | self.decoration = NCursesUI.Window( x, y, width, height, fg, bg ) | ||
| 112 | self.decoration.setBoxed() | ||
| 113 | self.decoration.win.hline( 2, 1, curses.ACS_HLINE, width-2 ) | ||
| 114 | self.setTitle( title ) | ||
| 115 | |||
| 116 | def setTitle( self, title ): | ||
| 117 | self.decoration.setText( 1, 1, title.center( self.dimensions[WIDTH]-2 ), curses.A_BOLD ) | ||
| 118 | |||
| 119 | #-------------------------------------------------------------------------# | ||
| 120 | # class TitleWindow( Window ): | ||
| 121 | #-------------------------------------------------------------------------# | ||
| 122 | # """Title Window""" | ||
| 123 | # def __init__( self, x, y, width, height ): | ||
| 124 | # NCursesUI.Window.__init__( self, x, y, width, height ) | ||
| 125 | # version = bb.__version__ | ||
| 126 | # title = "BitBake %s" % version | ||
| 127 | # credit = "(C) 2003-2007 Team BitBake" | ||
| 128 | # #self.win.hline( 2, 1, curses.ACS_HLINE, width-2 ) | ||
| 129 | # self.win.border() | ||
| 130 | # self.setText( 1, 1, title.center( self.dimensions[WIDTH]-2 ), curses.A_BOLD ) | ||
| 131 | # self.setText( 1, 2, credit.center( self.dimensions[WIDTH]-2 ), curses.A_BOLD ) | ||
| 132 | |||
| 133 | #-------------------------------------------------------------------------# | ||
| 134 | class ThreadActivityWindow( DecoratedWindow ): | ||
| 135 | #-------------------------------------------------------------------------# | ||
| 136 | """Thread Activity Window""" | ||
| 137 | def __init__( self, x, y, width, height ): | ||
| 138 | NCursesUI.DecoratedWindow.__init__( self, "Thread Activity", x, y, width, height ) | ||
| 139 | |||
| 140 | def setStatus( self, thread, text ): | ||
| 141 | line = "%02d: %s" % ( thread, text ) | ||
| 142 | width = self.dimensions[WIDTH] | ||
| 143 | if ( len(line) > width ): | ||
| 144 | line = line[:width-3] + "..." | ||
| 145 | else: | ||
| 146 | line = line.ljust( width ) | ||
| 147 | self.setText( 0, thread, line ) | ||
| 148 | |||
| 149 | #-------------------------------------------------------------------------# | ||
| 150 | class MainWindow( DecoratedWindow ): | ||
| 151 | #-------------------------------------------------------------------------# | ||
| 152 | """Main Window""" | ||
| 153 | def __init__( self, x, y, width, height ): | ||
| 154 | self.StatusPosition = width - MAXSTATUSLENGTH | ||
| 155 | NCursesUI.DecoratedWindow.__init__( self, None, x, y, width, height ) | ||
| 156 | curses.nl() | ||
| 157 | |||
| 158 | def setTitle( self, title ): | ||
| 159 | title = "BitBake %s" % bb.__version__ | ||
| 160 | self.decoration.setText( 2, 1, title, curses.A_BOLD ) | ||
| 161 | self.decoration.setText( self.StatusPosition - 8, 1, "Status:", curses.A_BOLD ) | ||
| 162 | |||
| 163 | def setStatus(self, status): | ||
| 164 | while len(status) < MAXSTATUSLENGTH: | ||
| 165 | status = status + " " | ||
| 166 | self.decoration.setText( self.StatusPosition, 1, status, curses.A_BOLD ) | ||
| 167 | |||
| 168 | |||
| 169 | #-------------------------------------------------------------------------# | ||
| 170 | class ShellOutputWindow( DecoratedWindow ): | ||
| 171 | #-------------------------------------------------------------------------# | ||
| 172 | """Interactive Command Line Output""" | ||
| 173 | def __init__( self, x, y, width, height ): | ||
| 174 | NCursesUI.DecoratedWindow.__init__( self, "Command Line Window", x, y, width, height ) | ||
| 175 | |||
| 176 | #-------------------------------------------------------------------------# | ||
| 177 | class ShellInputWindow( Window ): | ||
| 178 | #-------------------------------------------------------------------------# | ||
| 179 | """Interactive Command Line Input""" | ||
| 180 | def __init__( self, x, y, width, height ): | ||
| 181 | NCursesUI.Window.__init__( self, x, y, width, height ) | ||
| 182 | |||
| 183 | # self.textbox = Textbox( self.win ) | ||
| 184 | # t = threading.Thread() | ||
| 185 | # t.run = self.textbox.edit | ||
| 186 | # t.start() | ||
| 187 | |||
| 188 | #-------------------------------------------------------------------------# | ||
| 189 | def main(self, stdscr, server, eventHandler): | ||
| 190 | #-------------------------------------------------------------------------# | ||
| 191 | height, width = stdscr.getmaxyx() | ||
| 192 | |||
| 193 | # for now split it like that: | ||
| 194 | # MAIN_y + THREAD_y = 2/3 screen at the top | ||
| 195 | # MAIN_x = 2/3 left, THREAD_y = 1/3 right | ||
| 196 | # CLI_y = 1/3 of screen at the bottom | ||
| 197 | # CLI_x = full | ||
| 198 | |||
| 199 | main_left = 0 | ||
| 200 | main_top = 0 | ||
| 201 | main_height = ( height / 3 * 2 ) | ||
| 202 | main_width = ( width / 3 ) * 2 | ||
| 203 | clo_left = main_left | ||
| 204 | clo_top = main_top + main_height | ||
| 205 | clo_height = height - main_height - main_top - 1 | ||
| 206 | clo_width = width | ||
| 207 | cli_left = main_left | ||
| 208 | cli_top = clo_top + clo_height | ||
| 209 | cli_height = 1 | ||
| 210 | cli_width = width | ||
| 211 | thread_left = main_left + main_width | ||
| 212 | thread_top = main_top | ||
| 213 | thread_height = main_height | ||
| 214 | thread_width = width - main_width | ||
| 215 | |||
| 216 | #tw = self.TitleWindow( 0, 0, width, main_top ) | ||
| 217 | mw = self.MainWindow( main_left, main_top, main_width, main_height ) | ||
| 218 | taw = self.ThreadActivityWindow( thread_left, thread_top, thread_width, thread_height ) | ||
| 219 | clo = self.ShellOutputWindow( clo_left, clo_top, clo_width, clo_height ) | ||
| 220 | cli = self.ShellInputWindow( cli_left, cli_top, cli_width, cli_height ) | ||
| 221 | cli.setText( 0, 0, "BB>" ) | ||
| 222 | |||
| 223 | mw.setStatus("Idle") | ||
| 224 | |||
| 225 | helper = uihelper.BBUIHelper() | ||
| 226 | shutdown = 0 | ||
| 227 | |||
| 228 | try: | ||
| 229 | cmdline = server.runCommand(["getCmdLineAction"]) | ||
| 230 | if not cmdline: | ||
| 231 | return | ||
| 232 | ret = server.runCommand(cmdline) | ||
| 233 | if ret != True: | ||
| 234 | print "Couldn't get default commandlind! %s" % ret | ||
| 235 | return | ||
| 236 | except xmlrpclib.Fault, x: | ||
| 237 | print "XMLRPC Fault getting commandline:\n %s" % x | ||
| 238 | return | ||
| 239 | |||
| 240 | exitflag = False | ||
| 241 | while not exitflag: | ||
| 242 | try: | ||
| 243 | event = eventHandler.waitEvent(0.25) | ||
| 244 | if not event: | ||
| 245 | continue | ||
| 246 | helper.eventHandler(event) | ||
| 247 | #mw.appendText("%s\n" % event[0]) | ||
| 248 | if event[0].startswith('bb.event.Pkg'): | ||
| 249 | mw.appendText("NOTE: %s\n" % event[1]['_message']) | ||
| 250 | if event[0].startswith('bb.build.Task'): | ||
| 251 | mw.appendText("NOTE: %s\n" % event[1]['_message']) | ||
| 252 | if event[0].startswith('bb.msg.MsgDebug'): | ||
| 253 | mw.appendText('DEBUG: ' + event[1]['_message'] + '\n') | ||
| 254 | if event[0].startswith('bb.msg.MsgNote'): | ||
| 255 | mw.appendText('NOTE: ' + event[1]['_message'] + '\n') | ||
| 256 | if event[0].startswith('bb.msg.MsgWarn'): | ||
| 257 | mw.appendText('WARNING: ' + event[1]['_message'] + '\n') | ||
| 258 | if event[0].startswith('bb.msg.MsgError'): | ||
| 259 | mw.appendText('ERROR: ' + event[1]['_message'] + '\n') | ||
| 260 | if event[0].startswith('bb.msg.MsgFatal'): | ||
| 261 | mw.appendText('FATAL: ' + event[1]['_message'] + '\n') | ||
| 262 | if event[0].startswith('bb.event.ParseProgress'): | ||
| 263 | x = event[1]['sofar'] | ||
| 264 | y = event[1]['total'] | ||
| 265 | if x == y: | ||
| 266 | mw.setStatus("Idle") | ||
| 267 | mw.appendText("Parsing finished. %d cached, %d parsed, %d skipped, %d masked." | ||
| 268 | % ( event[1]['cached'], event[1]['parsed'], event[1]['skipped'], event[1]['masked'] )) | ||
| 269 | else: | ||
| 270 | mw.setStatus("Parsing: %s (%04d/%04d) [%2d %%]" % ( parsespin.next(), x, y, x*100/y ) ) | ||
| 271 | # if event[0].startswith('bb.build.TaskFailed'): | ||
| 272 | # if event[1]['logfile']: | ||
| 273 | # if data.getVar("BBINCLUDELOGS", d): | ||
| 274 | # bb.msg.error(bb.msg.domain.Build, "log data follows (%s)" % logfile) | ||
| 275 | # number_of_lines = data.getVar("BBINCLUDELOGS_LINES", d) | ||
| 276 | # if number_of_lines: | ||
| 277 | # os.system('tail -n%s %s' % (number_of_lines, logfile)) | ||
| 278 | # else: | ||
| 279 | # f = open(logfile, "r") | ||
| 280 | # while True: | ||
| 281 | # l = f.readline() | ||
| 282 | # if l == '': | ||
| 283 | # break | ||
| 284 | # l = l.rstrip() | ||
| 285 | # print '| %s' % l | ||
| 286 | # f.close() | ||
| 287 | # else: | ||
| 288 | # bb.msg.error(bb.msg.domain.Build, "see log in %s" % logfile) | ||
| 289 | |||
| 290 | if event[0] == 'bb.command.CookerCommandCompleted': | ||
| 291 | exitflag = True | ||
| 292 | if event[0] == 'bb.command.CookerCommandFailed': | ||
| 293 | mw.appendText("Command execution failed: %s" % event[1]['error']) | ||
| 294 | time.sleep(2) | ||
| 295 | exitflag = True | ||
| 296 | if event[0] == 'bb.cooker.CookerExit': | ||
| 297 | exitflag = True | ||
| 298 | |||
| 299 | if helper.needUpdate: | ||
| 300 | activetasks, failedtasks = helper.getTasks() | ||
| 301 | taw.erase() | ||
| 302 | taw.setText(0, 0, "") | ||
| 303 | if activetasks: | ||
| 304 | taw.appendText("Active Tasks:\n") | ||
| 305 | for task in activetasks: | ||
| 306 | taw.appendText(task) | ||
| 307 | if failedtasks: | ||
| 308 | taw.appendText("Failed Tasks:\n") | ||
| 309 | for task in failedtasks: | ||
| 310 | taw.appendText(task) | ||
| 311 | |||
| 312 | curses.doupdate() | ||
| 313 | except KeyboardInterrupt: | ||
| 314 | if shutdown == 2: | ||
| 315 | mw.appendText("Third Keyboard Interrupt, exit.\n") | ||
| 316 | exitflag = True | ||
| 317 | if shutdown == 1: | ||
| 318 | mw.appendText("Second Keyboard Interrupt, stopping...\n") | ||
| 319 | server.runCommand(["stateStop"]) | ||
| 320 | if shutdown == 0: | ||
| 321 | mw.appendText("Keyboard Interrupt, closing down...\n") | ||
| 322 | server.runCommand(["stateShutdown"]) | ||
| 323 | shutdown = shutdown + 1 | ||
| 324 | pass | ||
| 325 | |||
| 326 | def init(server, eventHandler): | ||
| 327 | ui = NCursesUI() | ||
| 328 | try: | ||
| 329 | curses.wrapper(ui.main, server, eventHandler) | ||
| 330 | except: | ||
| 331 | import traceback | ||
| 332 | traceback.print_exc() | ||
| 333 | |||
diff --git a/bitbake-dev/lib/bb/ui/uievent.py b/bitbake-dev/lib/bb/ui/uievent.py new file mode 100644 index 0000000000..9d724d7fc5 --- /dev/null +++ b/bitbake-dev/lib/bb/ui/uievent.py | |||
| @@ -0,0 +1,127 @@ | |||
| 1 | # ex:ts=4:sw=4:sts=4:et | ||
| 2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
| 3 | # | ||
| 4 | # Copyright (C) 2006 - 2007 Michael 'Mickey' Lauer | ||
| 5 | # Copyright (C) 2006 - 2007 Richard Purdie | ||
| 6 | # | ||
| 7 | # This program is free software; you can redistribute it and/or modify | ||
| 8 | # it under the terms of the GNU General Public License version 2 as | ||
| 9 | # published by the Free Software Foundation. | ||
| 10 | # | ||
| 11 | # This program is distributed in the hope that it will be useful, | ||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | # GNU General Public License for more details. | ||
| 15 | # | ||
| 16 | # You should have received a copy of the GNU General Public License along | ||
| 17 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 19 | |||
| 20 | |||
| 21 | """ | ||
| 22 | Use this class to fork off a thread to recieve event callbacks from the bitbake | ||
| 23 | server and queue them for the UI to process. This process must be used to avoid | ||
| 24 | client/server deadlocks. | ||
| 25 | """ | ||
| 26 | |||
| 27 | import sys, socket, threading | ||
| 28 | from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler | ||
| 29 | |||
| 30 | class BBUIEventQueue: | ||
| 31 | def __init__(self, BBServer): | ||
| 32 | |||
| 33 | self.eventQueue = [] | ||
| 34 | self.eventQueueLock = threading.Lock() | ||
| 35 | self.eventQueueNotify = threading.Event() | ||
| 36 | |||
| 37 | self.BBServer = BBServer | ||
| 38 | |||
| 39 | self.t = threading.Thread() | ||
| 40 | self.t.setDaemon(True) | ||
| 41 | self.t.run = self.startCallbackHandler | ||
| 42 | self.t.start() | ||
| 43 | |||
| 44 | def getEvent(self): | ||
| 45 | |||
| 46 | self.eventQueueLock.acquire() | ||
| 47 | |||
| 48 | if len(self.eventQueue) == 0: | ||
| 49 | self.eventQueueLock.release() | ||
| 50 | return None | ||
| 51 | |||
| 52 | item = self.eventQueue.pop(0) | ||
| 53 | |||
| 54 | if len(self.eventQueue) == 0: | ||
| 55 | self.eventQueueNotify.clear() | ||
| 56 | |||
| 57 | self.eventQueueLock.release() | ||
| 58 | |||
| 59 | return item | ||
| 60 | |||
| 61 | def waitEvent(self, delay): | ||
| 62 | self.eventQueueNotify.wait(delay) | ||
| 63 | return self.getEvent() | ||
| 64 | |||
| 65 | def queue_event(self, event): | ||
| 66 | |||
| 67 | self.eventQueueLock.acquire() | ||
| 68 | self.eventQueue.append(event) | ||
| 69 | self.eventQueueNotify.set() | ||
| 70 | self.eventQueueLock.release() | ||
| 71 | |||
| 72 | def startCallbackHandler(self): | ||
| 73 | |||
| 74 | server = UIXMLRPCServer() | ||
| 75 | self.host, self.port = server.socket.getsockname() | ||
| 76 | |||
| 77 | server.register_function( self.system_quit, "event.quit" ) | ||
| 78 | server.register_function( self.queue_event, "event.send" ) | ||
| 79 | server.socket.settimeout(1) | ||
| 80 | |||
| 81 | self.EventHandle = self.BBServer.registerEventHandler(self.host, self.port) | ||
| 82 | |||
| 83 | self.server = server | ||
| 84 | while not server.quit: | ||
| 85 | server.handle_request() | ||
| 86 | server.server_close() | ||
| 87 | |||
| 88 | def system_quit( self ): | ||
| 89 | """ | ||
| 90 | Shut down the callback thread | ||
| 91 | """ | ||
| 92 | try: | ||
| 93 | self.BBServer.unregisterEventHandler(self.EventHandle) | ||
| 94 | except: | ||
| 95 | pass | ||
| 96 | self.server.quit = True | ||
| 97 | |||
| 98 | class UIXMLRPCServer (SimpleXMLRPCServer): | ||
| 99 | |||
| 100 | def __init__( self, interface = ("localhost", 0) ): | ||
| 101 | self.quit = False | ||
| 102 | SimpleXMLRPCServer.__init__( self, | ||
| 103 | interface, | ||
| 104 | requestHandler=SimpleXMLRPCRequestHandler, | ||
| 105 | logRequests=False, allow_none=True) | ||
| 106 | |||
| 107 | def get_request(self): | ||
| 108 | while not self.quit: | ||
| 109 | try: | ||
| 110 | sock, addr = self.socket.accept() | ||
| 111 | sock.settimeout(1) | ||
| 112 | return (sock, addr) | ||
| 113 | except socket.timeout: | ||
| 114 | pass | ||
| 115 | return (None,None) | ||
| 116 | |||
| 117 | def close_request(self, request): | ||
| 118 | if request is None: | ||
| 119 | return | ||
| 120 | SimpleXMLRPCServer.close_request(self, request) | ||
| 121 | |||
| 122 | def process_request(self, request, client_address): | ||
| 123 | if request is None: | ||
| 124 | return | ||
| 125 | SimpleXMLRPCServer.process_request(self, request, client_address) | ||
| 126 | |||
| 127 | |||
diff --git a/bitbake-dev/lib/bb/ui/uihelper.py b/bitbake-dev/lib/bb/ui/uihelper.py new file mode 100644 index 0000000000..246844c9d2 --- /dev/null +++ b/bitbake-dev/lib/bb/ui/uihelper.py | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | # ex:ts=4:sw=4:sts=4:et | ||
| 2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
| 3 | # | ||
| 4 | # Copyright (C) 2006 - 2007 Michael 'Mickey' Lauer | ||
| 5 | # Copyright (C) 2006 - 2007 Richard Purdie | ||
| 6 | # | ||
| 7 | # This program is free software; you can redistribute it and/or modify | ||
| 8 | # it under the terms of the GNU General Public License version 2 as | ||
| 9 | # published by the Free Software Foundation. | ||
| 10 | # | ||
| 11 | # This program is distributed in the hope that it will be useful, | ||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | # GNU General Public License for more details. | ||
| 15 | # | ||
| 16 | # You should have received a copy of the GNU General Public License along | ||
| 17 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 19 | |||
| 20 | class BBUIHelper: | ||
| 21 | def __init__(self): | ||
| 22 | self.needUpdate = False | ||
| 23 | self.running_tasks = {} | ||
| 24 | self.failed_tasks = {} | ||
| 25 | |||
| 26 | def eventHandler(self, event): | ||
| 27 | if event[0].startswith('bb.build.TaskStarted'): | ||
| 28 | self.running_tasks["%s %s\n" % (event[1]['_package'], event[1]['_task'])] = "" | ||
| 29 | self.needUpdate = True | ||
| 30 | if event[0].startswith('bb.build.TaskSucceeded'): | ||
| 31 | del self.running_tasks["%s %s\n" % (event[1]['_package'], event[1]['_task'])] | ||
| 32 | self.needUpdate = True | ||
| 33 | if event[0].startswith('bb.build.TaskFailed'): | ||
| 34 | del self.running_tasks["%s %s\n" % (event[1]['_package'], event[1]['_task'])] | ||
| 35 | self.failed_tasks["%s %s\n" % (event[1]['_package'], event[1]['_task'])] = "" | ||
| 36 | self.needUpdate = True | ||
| 37 | |||
| 38 | # Add runqueue event handling | ||
| 39 | #if event[0].startswith('bb.runqueue.runQueueTaskCompleted'): | ||
| 40 | # a = 1 | ||
| 41 | #if event[0].startswith('bb.runqueue.runQueueTaskStarted'): | ||
| 42 | # a = 1 | ||
| 43 | #if event[0].startswith('bb.runqueue.runQueueTaskFailed'): | ||
| 44 | # a = 1 | ||
| 45 | #if event[0].startswith('bb.runqueue.runQueueExitWait'): | ||
| 46 | # a = 1 | ||
| 47 | |||
| 48 | def getTasks(self): | ||
| 49 | return (self.running_tasks, self.failed_tasks) | ||
