diff options
-rw-r--r-- | bitbake-dev/lib/bb/ui/crumbs/__init__.py | 18 | ||||
-rw-r--r-- | bitbake-dev/lib/bb/ui/crumbs/runningbuild.py | 169 | ||||
-rw-r--r-- | bitbake-dev/lib/bb/ui/goggle.py | 146 |
3 files changed, 188 insertions, 145 deletions
diff --git a/bitbake-dev/lib/bb/ui/crumbs/__init__.py b/bitbake-dev/lib/bb/ui/crumbs/__init__.py new file mode 100644 index 0000000000..c6a377a8e6 --- /dev/null +++ b/bitbake-dev/lib/bb/ui/crumbs/__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/crumbs/runningbuild.py b/bitbake-dev/lib/bb/ui/crumbs/runningbuild.py new file mode 100644 index 0000000000..b9aba5b8cc --- /dev/null +++ b/bitbake-dev/lib/bb/ui/crumbs/runningbuild.py | |||
@@ -0,0 +1,169 @@ | |||
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 | |||
24 | class RunningBuildModel (gtk.TreeStore): | ||
25 | (COL_TYPE, COL_PACKAGE, COL_TASK, COL_MESSAGE, COL_ICON, COL_ACTIVE) = (0, 1, 2, 3, 4, 5) | ||
26 | def __init__ (self): | ||
27 | gtk.TreeStore.__init__ (self, | ||
28 | gobject.TYPE_STRING, | ||
29 | gobject.TYPE_STRING, | ||
30 | gobject.TYPE_STRING, | ||
31 | gobject.TYPE_STRING, | ||
32 | gobject.TYPE_STRING, | ||
33 | gobject.TYPE_BOOLEAN) | ||
34 | |||
35 | class RunningBuild (gobject.GObject): | ||
36 | __gsignals__ = { | ||
37 | 'build-finished' : (gobject.SIGNAL_RUN_LAST, | ||
38 | gobject.TYPE_NONE, | ||
39 | ()) | ||
40 | } | ||
41 | pids_to_task = {} | ||
42 | tasks_to_iter = {} | ||
43 | |||
44 | def __init__ (self): | ||
45 | gobject.GObject.__init__ (self) | ||
46 | self.model = RunningBuildModel() | ||
47 | |||
48 | def handle_event (self, event): | ||
49 | # Handle an event from the event queue, this may result in updating | ||
50 | # the model and thus the UI. Or it may be to tell us that the build | ||
51 | # has finished successfully (or not, as the case may be.) | ||
52 | |||
53 | parent = None | ||
54 | pid = 0 | ||
55 | package = None | ||
56 | task = None | ||
57 | |||
58 | # If we have a pid attached to this message/event try and get the | ||
59 | # (package, task) pair for it. If we get that then get the parent iter | ||
60 | # for the message. | ||
61 | if event[1].has_key ('pid'): | ||
62 | pid = event[1]['pid'] | ||
63 | if self.pids_to_task.has_key(pid): | ||
64 | (package, task) = self.pids_to_task[pid] | ||
65 | parent = self.tasks_to_iter[(package, task)] | ||
66 | |||
67 | if event[0].startswith('bb.msg.Msg'): | ||
68 | # Set a pretty icon for the message based on it's type. | ||
69 | if (event[0].startswith ('bb.msg.MsgWarn')): | ||
70 | icon = "dialog-warning" | ||
71 | elif (event[0].startswith ('bb.msg.MsgErr')): | ||
72 | icon = "dialog-error" | ||
73 | else: | ||
74 | icon = None | ||
75 | |||
76 | # Ignore the "Running task i of n .." messages | ||
77 | if (event[1]['_message'].startswith ("Running task")): | ||
78 | return | ||
79 | |||
80 | # Add the message to the tree either at the top level if parent is | ||
81 | # None otherwise as a descendent of a task. | ||
82 | self.model.append (parent, | ||
83 | (event[0].split()[-1], # e.g. MsgWarn, MsgError | ||
84 | package, | ||
85 | task, | ||
86 | event[1]['_message'], | ||
87 | icon, | ||
88 | False)) | ||
89 | elif event[0].startswith('bb.build.TaskStarted'): | ||
90 | (package, task) = (event[1]['_package'], event[1]['_task']) | ||
91 | |||
92 | # Save out this PID. | ||
93 | self.pids_to_task[pid] = (package,task) | ||
94 | |||
95 | # Check if we already have this package in our model. If so then | ||
96 | # that can be the parent for the task. Otherwise we create a new | ||
97 | # top level for the package. | ||
98 | if (self.tasks_to_iter.has_key ((package, None))): | ||
99 | parent = self.tasks_to_iter[(package, None)] | ||
100 | else: | ||
101 | parent = self.model.append (None, (None, | ||
102 | package, | ||
103 | None, | ||
104 | "Package: %s" % (package), | ||
105 | None, | ||
106 | False)) | ||
107 | self.tasks_to_iter[(package, None)] = parent | ||
108 | |||
109 | # Because this parent package now has an active child mark it as | ||
110 | # such. | ||
111 | self.model.set(parent, self.model.COL_ICON, "gtk-execute") | ||
112 | |||
113 | # Add an entry in the model for this task | ||
114 | i = self.model.append (parent, (None, | ||
115 | package, | ||
116 | task, | ||
117 | "Task: %s" % (task), | ||
118 | None, | ||
119 | False)) | ||
120 | |||
121 | # Save out the iter so that we can find it when we have a message | ||
122 | # that we need to attach to a task. | ||
123 | self.tasks_to_iter[(package, task)] = i | ||
124 | |||
125 | # Mark this task as active. | ||
126 | self.model.set(i, self.model.COL_ICON, "gtk-execute") | ||
127 | |||
128 | elif event[0].startswith('bb.build.Task'): | ||
129 | |||
130 | if event[0].startswith('bb.build.TaskFailed'): | ||
131 | # Mark the task as failed | ||
132 | i = self.tasks_to_iter[(package, task)] | ||
133 | self.model.set(i, self.model.COL_ICON, "dialog-error") | ||
134 | |||
135 | # Mark the parent package as failed | ||
136 | i = self.tasks_to_iter[(package, None)] | ||
137 | self.model.set(i, self.model.COL_ICON, "dialog-error") | ||
138 | else: | ||
139 | # Mark the task as inactive | ||
140 | i = self.tasks_to_iter[(package, task)] | ||
141 | self.model.set(i, self.model.COL_ICON, None) | ||
142 | |||
143 | # Mark the parent package as inactive | ||
144 | i = self.tasks_to_iter[(package, None)] | ||
145 | self.model.set(i, self.model.COL_ICON, None) | ||
146 | |||
147 | |||
148 | # Clear the iters and the pids since when the task goes away the | ||
149 | # pid will no longer be used for messages | ||
150 | del self.tasks_to_iter[(package, task)] | ||
151 | del self.pids_to_task[pid] | ||
152 | |||
153 | class RunningBuildTreeView (gtk.TreeView): | ||
154 | def __init__ (self): | ||
155 | gtk.TreeView.__init__ (self) | ||
156 | |||
157 | # The icon that indicates whether we're building or failed. | ||
158 | renderer = gtk.CellRendererPixbuf () | ||
159 | col = gtk.TreeViewColumn ("Status", renderer) | ||
160 | col.add_attribute (renderer, "icon-name", 4) | ||
161 | self.append_column (col) | ||
162 | |||
163 | # The message of the build. | ||
164 | renderer = gtk.CellRendererText () | ||
165 | col = gtk.TreeViewColumn ("Message", renderer, text=3) | ||
166 | self.append_column (col) | ||
167 | |||
168 | |||
169 | |||
diff --git a/bitbake-dev/lib/bb/ui/goggle.py b/bitbake-dev/lib/bb/ui/goggle.py index 651a0449b0..0118a356fa 100644 --- a/bitbake-dev/lib/bb/ui/goggle.py +++ b/bitbake-dev/lib/bb/ui/goggle.py | |||
@@ -22,6 +22,7 @@ import gobject | |||
22 | import gtk | 22 | import gtk |
23 | import threading | 23 | import threading |
24 | import bb.ui.uihelper | 24 | import bb.ui.uihelper |
25 | from bb.ui.crumbs.runningbuild import RunningBuildTreeView, RunningBuild | ||
25 | 26 | ||
26 | def event_handle_idle_func (eventHandler, build): | 27 | def event_handle_idle_func (eventHandler, build): |
27 | 28 | ||
@@ -33,151 +34,6 @@ def event_handle_idle_func (eventHandler, build): | |||
33 | 34 | ||
34 | return True | 35 | return True |
35 | 36 | ||
36 | class RunningBuildModel (gtk.TreeStore): | ||
37 | (COL_TYPE, COL_PACKAGE, COL_TASK, COL_MESSAGE, COL_ICON, COL_ACTIVE) = (0, 1, 2, 3, 4, 5) | ||
38 | def __init__ (self): | ||
39 | gtk.TreeStore.__init__ (self, | ||
40 | gobject.TYPE_STRING, | ||
41 | gobject.TYPE_STRING, | ||
42 | gobject.TYPE_STRING, | ||
43 | gobject.TYPE_STRING, | ||
44 | gobject.TYPE_STRING, | ||
45 | gobject.TYPE_BOOLEAN) | ||
46 | |||
47 | class RunningBuild (gobject.GObject): | ||
48 | __gsignals__ = { | ||
49 | 'build-finished' : (gobject.SIGNAL_RUN_LAST, | ||
50 | gobject.TYPE_NONE, | ||
51 | ()) | ||
52 | } | ||
53 | pids_to_task = {} | ||
54 | tasks_to_iter = {} | ||
55 | |||
56 | def __init__ (self): | ||
57 | gobject.GObject.__init__ (self) | ||
58 | self.model = RunningBuildModel() | ||
59 | |||
60 | def handle_event (self, event): | ||
61 | # Handle an event from the event queue, this may result in updating | ||
62 | # the model and thus the UI. Or it may be to tell us that the build | ||
63 | # has finished successfully (or not, as the case may be.) | ||
64 | |||
65 | parent = None | ||
66 | pid = 0 | ||
67 | package = None | ||
68 | task = None | ||
69 | |||
70 | # If we have a pid attached to this message/event try and get the | ||
71 | # (package, task) pair for it. If we get that then get the parent iter | ||
72 | # for the message. | ||
73 | if event[1].has_key ('pid'): | ||
74 | pid = event[1]['pid'] | ||
75 | if self.pids_to_task.has_key(pid): | ||
76 | (package, task) = self.pids_to_task[pid] | ||
77 | parent = self.tasks_to_iter[(package, task)] | ||
78 | |||
79 | if event[0].startswith('bb.msg.Msg'): | ||
80 | # Set a pretty icon for the message based on it's type. | ||
81 | if (event[0].startswith ('bb.msg.MsgWarn')): | ||
82 | icon = "dialog-warning" | ||
83 | elif (event[0].startswith ('bb.msg.MsgErr')): | ||
84 | icon = "dialog-error" | ||
85 | else: | ||
86 | icon = None | ||
87 | |||
88 | # Ignore the "Running task i of n .." messages | ||
89 | if (event[1]['_message'].startswith ("Running task")): | ||
90 | return | ||
91 | |||
92 | # Add the message to the tree either at the top level if parent is | ||
93 | # None otherwise as a descendent of a task. | ||
94 | self.model.append (parent, | ||
95 | (event[0].split()[-1], # e.g. MsgWarn, MsgError | ||
96 | package, | ||
97 | task, | ||
98 | event[1]['_message'], | ||
99 | icon, | ||
100 | False)) | ||
101 | elif event[0].startswith('bb.build.TaskStarted'): | ||
102 | (package, task) = (event[1]['_package'], event[1]['_task']) | ||
103 | |||
104 | # Save out this PID. | ||
105 | self.pids_to_task[pid] = (package,task) | ||
106 | |||
107 | # Check if we already have this package in our model. If so then | ||
108 | # that can be the parent for the task. Otherwise we create a new | ||
109 | # top level for the package. | ||
110 | if (self.tasks_to_iter.has_key ((package, None))): | ||
111 | parent = self.tasks_to_iter[(package, None)] | ||
112 | else: | ||
113 | parent = self.model.append (None, (None, | ||
114 | package, | ||
115 | None, | ||
116 | "Package: %s" % (package), | ||
117 | None, | ||
118 | False)) | ||
119 | self.tasks_to_iter[(package, None)] = parent | ||
120 | |||
121 | # Because this parent package now has an active child mark it as | ||
122 | # such. | ||
123 | self.model.set(parent, self.model.COL_ICON, "gtk-execute") | ||
124 | |||
125 | # Add an entry in the model for this task | ||
126 | i = self.model.append (parent, (None, | ||
127 | package, | ||
128 | task, | ||
129 | "Task: %s" % (task), | ||
130 | None, | ||
131 | False)) | ||
132 | |||
133 | # Save out the iter so that we can find it when we have a message | ||
134 | # that we need to attach to a task. | ||
135 | self.tasks_to_iter[(package, task)] = i | ||
136 | |||
137 | # Mark this task as active. | ||
138 | self.model.set(i, self.model.COL_ICON, "gtk-execute") | ||
139 | |||
140 | elif event[0].startswith('bb.build.Task'): | ||
141 | |||
142 | if event[0].startswith('bb.build.TaskFailed'): | ||
143 | # Mark the task as failed | ||
144 | i = self.tasks_to_iter[(package, task)] | ||
145 | self.model.set(i, self.model.COL_ICON, "dialog-error") | ||
146 | |||
147 | # Mark the parent package as failed | ||
148 | i = self.tasks_to_iter[(package, None)] | ||
149 | self.model.set(i, self.model.COL_ICON, "dialog-error") | ||
150 | else: | ||
151 | # Mark the task as inactive | ||
152 | i = self.tasks_to_iter[(package, task)] | ||
153 | self.model.set(i, self.model.COL_ICON, None) | ||
154 | |||
155 | # Mark the parent package as inactive | ||
156 | i = self.tasks_to_iter[(package, None)] | ||
157 | self.model.set(i, self.model.COL_ICON, None) | ||
158 | |||
159 | |||
160 | # Clear the iters and the pids since when the task goes away the | ||
161 | # pid will no longer be used for messages | ||
162 | del self.tasks_to_iter[(package, task)] | ||
163 | del self.pids_to_task[pid] | ||
164 | |||
165 | class RunningBuildTreeView (gtk.TreeView): | ||
166 | def __init__ (self): | ||
167 | gtk.TreeView.__init__ (self) | ||
168 | |||
169 | # The icon that indicates whether we're building or failed. | ||
170 | renderer = gtk.CellRendererPixbuf () | ||
171 | col = gtk.TreeViewColumn ("Status", renderer) | ||
172 | col.add_attribute (renderer, "icon-name", 4) | ||
173 | self.append_column (col) | ||
174 | |||
175 | # The message of the build. | ||
176 | renderer = gtk.CellRendererText () | ||
177 | col = gtk.TreeViewColumn ("Message", renderer, text=3) | ||
178 | self.append_column (col) | ||
179 | |||
180 | |||
181 | class MainWindow (gtk.Window): | 37 | class MainWindow (gtk.Window): |
182 | def __init__ (self): | 38 | def __init__ (self): |
183 | gtk.Window.__init__ (self, gtk.WINDOW_TOPLEVEL) | 39 | gtk.Window.__init__ (self, gtk.WINDOW_TOPLEVEL) |