summaryrefslogtreecommitdiffstats
path: root/bitbake-dev/lib/bb/ui/crumbs/runningbuild.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake-dev/lib/bb/ui/crumbs/runningbuild.py')
-rw-r--r--bitbake-dev/lib/bb/ui/crumbs/runningbuild.py169
1 files changed, 169 insertions, 0 deletions
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
21import gobject
22import gtk
23
24class 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
35class 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
153class 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