diff options
Diffstat (limited to 'bitbake/lib/bb/ui/goggle.py')
-rw-r--r-- | bitbake/lib/bb/ui/goggle.py | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/bitbake/lib/bb/ui/goggle.py b/bitbake/lib/bb/ui/goggle.py new file mode 100644 index 0000000000..f4ee7b41ae --- /dev/null +++ b/bitbake/lib/bb/ui/goggle.py | |||
@@ -0,0 +1,121 @@ | |||
1 | # | ||
2 | # BitBake Graphical GTK User Interface | ||
3 | # | ||
4 | # Copyright (C) 2008 Intel Corporation | ||
5 | # | ||
6 | # Authored by Rob Bradford <rob@linux.intel.com> | ||
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 gobject | ||
22 | import gtk | ||
23 | import xmlrpclib | ||
24 | from bb.ui.crumbs.runningbuild import RunningBuildTreeView, RunningBuild | ||
25 | from bb.ui.crumbs.progress import ProgressBar | ||
26 | |||
27 | import Queue | ||
28 | |||
29 | |||
30 | def event_handle_idle_func (eventHandler, build, pbar): | ||
31 | |||
32 | # Consume as many messages as we can in the time available to us | ||
33 | event = eventHandler.getEvent() | ||
34 | while event: | ||
35 | build.handle_event (event, pbar) | ||
36 | event = eventHandler.getEvent() | ||
37 | |||
38 | return True | ||
39 | |||
40 | def scroll_tv_cb (model, path, iter, view): | ||
41 | view.scroll_to_cell (path) | ||
42 | |||
43 | |||
44 | # @todo hook these into the GUI so the user has feedback... | ||
45 | def running_build_failed_cb (running_build): | ||
46 | pass | ||
47 | |||
48 | |||
49 | def running_build_succeeded_cb (running_build): | ||
50 | pass | ||
51 | |||
52 | |||
53 | class MainWindow (gtk.Window): | ||
54 | def __init__ (self): | ||
55 | gtk.Window.__init__ (self, gtk.WINDOW_TOPLEVEL) | ||
56 | |||
57 | # Setup tree view and the scrolled window | ||
58 | scrolled_window = gtk.ScrolledWindow () | ||
59 | self.add (scrolled_window) | ||
60 | self.cur_build_tv = RunningBuildTreeView() | ||
61 | self.connect("delete-event", gtk.main_quit) | ||
62 | self.set_default_size(640, 480) | ||
63 | scrolled_window.add (self.cur_build_tv) | ||
64 | |||
65 | |||
66 | def main (server, eventHandler, params): | ||
67 | gobject.threads_init() | ||
68 | gtk.gdk.threads_init() | ||
69 | |||
70 | window = MainWindow () | ||
71 | window.show_all () | ||
72 | pbar = ProgressBar(window) | ||
73 | pbar.connect("delete-event", gtk.main_quit) | ||
74 | |||
75 | # Create the object for the current build | ||
76 | running_build = RunningBuild () | ||
77 | window.cur_build_tv.set_model (running_build.model) | ||
78 | running_build.model.connect("row-inserted", scroll_tv_cb, window.cur_build_tv) | ||
79 | running_build.connect ("build-succeeded", running_build_succeeded_cb) | ||
80 | running_build.connect ("build-failed", running_build_failed_cb) | ||
81 | |||
82 | try: | ||
83 | params.updateFromServer(server) | ||
84 | cmdline = params.parseActions() | ||
85 | if not cmdline: | ||
86 | print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") | ||
87 | return 1 | ||
88 | if 'msg' in cmdline and cmdline['msg']: | ||
89 | logger.error(cmdline['msg']) | ||
90 | return 1 | ||
91 | cmdline = cmdline['action'] | ||
92 | ret, error = server.runCommand(cmdline) | ||
93 | if error: | ||
94 | print("Error running command '%s': %s" % (cmdline, error)) | ||
95 | return 1 | ||
96 | elif ret != True: | ||
97 | print("Error running command '%s': returned %s" % (cmdline, ret)) | ||
98 | return 1 | ||
99 | except xmlrpclib.Fault as x: | ||
100 | print("XMLRPC Fault getting commandline:\n %s" % x) | ||
101 | return 1 | ||
102 | |||
103 | # Use a timeout function for probing the event queue to find out if we | ||
104 | # have a message waiting for us. | ||
105 | gobject.timeout_add (100, | ||
106 | event_handle_idle_func, | ||
107 | eventHandler, | ||
108 | running_build, | ||
109 | pbar) | ||
110 | |||
111 | try: | ||
112 | gtk.main() | ||
113 | except EnvironmentError as ioerror: | ||
114 | # ignore interrupted io | ||
115 | if ioerror.args[0] == 4: | ||
116 | pass | ||
117 | except KeyboardInterrupt: | ||
118 | pass | ||
119 | finally: | ||
120 | server.runCommand(["stateForceShutdown"]) | ||
121 | |||