summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-05-08 11:48:35 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-05-08 22:56:45 +0100
commit020911ab590624406f406237f8750b0ea8be320b (patch)
treeb27790bf6a76204f0288062bad03cf0b94d8b24e /scripts
parentd13b904305289df1d3ab81f86350d7ff99d2966d (diff)
downloadpoky-020911ab590624406f406237f8750b0ea8be320b.tar.gz
scripts/pybootchart: Port to python3
This updates the pybootchart code (used for viewing build timing profiles) to use python3. The bulk of the changes are to use gi instead of pygtk, i.e. port from gtk+2 to gtk+3. The main change is to make the bootchart widget inherit gtk.Scrollable and change the way the scrollbars are implemented to match the new method upstream. The drawing code used cairo already so can remain unchanged, (From OE-Core rev: 949144681ad7f536732169351cab6d0612e9c566) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/pybootchartgui/pybootchartgui.py2
-rw-r--r--scripts/pybootchartgui/pybootchartgui/draw.py14
-rw-r--r--scripts/pybootchartgui/pybootchartgui/gui.py208
-rw-r--r--scripts/pybootchartgui/pybootchartgui/parsing.py12
4 files changed, 118 insertions, 118 deletions
diff --git a/scripts/pybootchartgui/pybootchartgui.py b/scripts/pybootchartgui/pybootchartgui.py
index 7ce1a5be40..1c4062b42c 100755
--- a/scripts/pybootchartgui/pybootchartgui.py
+++ b/scripts/pybootchartgui/pybootchartgui.py
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/env python3
2# 2#
3# This file is part of pybootchartgui. 3# This file is part of pybootchartgui.
4 4
diff --git a/scripts/pybootchartgui/pybootchartgui/draw.py b/scripts/pybootchartgui/pybootchartgui/draw.py
index 019070a7db..99b3caacc7 100644
--- a/scripts/pybootchartgui/pybootchartgui/draw.py
+++ b/scripts/pybootchartgui/pybootchartgui/draw.py
@@ -19,6 +19,7 @@ import math
19import re 19import re
20import random 20import random
21import colorsys 21import colorsys
22import functools
22from operator import itemgetter 23from operator import itemgetter
23 24
24class RenderOptions: 25class RenderOptions:
@@ -449,7 +450,7 @@ def render_charts(ctx, options, clip, trace, curr_y, w, h, sec_w):
449 [(sample.time, 450 [(sample.time,
450 # Sum up used space of all volumes including the current one 451 # Sum up used space of all volumes including the current one
451 # so that the graphs appear as stacked on top of each other. 452 # so that the graphs appear as stacked on top of each other.
452 reduce(lambda x,y: x+y, 453 functools.reduce(lambda x,y: x+y,
453 [sample.records[volume] - min_used[volume] 454 [sample.records[volume] - min_used[volume]
454 for volume in volumes[0:i] 455 for volume in volumes[0:i]
455 if volume in sample.records], 456 if volume in sample.records],
@@ -501,7 +502,7 @@ def render_processes_chart(ctx, options, trace, curr_y, w, h, sec_w):
501 TASK_COLOR_SYSROOT, off_x+360, curr_y + 45, leg_s) 502 TASK_COLOR_SYSROOT, off_x+360, curr_y + 45, leg_s)
502 draw_legend_box (ctx, "Package", \ 503 draw_legend_box (ctx, "Package", \
503 TASK_COLOR_PACKAGE, off_x+480, curr_y + 45, leg_s) 504 TASK_COLOR_PACKAGE, off_x+480, curr_y + 45, leg_s)
504 draw_legend_box (ctx, "Package Write", 505 draw_legend_box (ctx, "Package Write", \
505 TASK_COLOR_PACKAGE_WRITE, off_x+600, curr_y + 45, leg_s) 506 TASK_COLOR_PACKAGE_WRITE, off_x+600, curr_y + 45, leg_s)
506 507
507 ctx.set_font_size(PROC_TEXT_FONT_SIZE) 508 ctx.set_font_size(PROC_TEXT_FONT_SIZE)
@@ -518,13 +519,14 @@ def render_processes_chart(ctx, options, trace, curr_y, w, h, sec_w):
518 trace.processes[val][1] - s < options.app_options.mintime: 519 trace.processes[val][1] - s < options.app_options.mintime:
519 continue 520 continue
520 task = val.split(":")[1] 521 task = val.split(":")[1]
521 #print val 522 #print(val)
522 #print trace.processes[val][1] 523 #print(trace.processes[val][1])
523 #print s 524 #print(s)
525
524 x = chart_rect[0] + (s - offset) * sec_w 526 x = chart_rect[0] + (s - offset) * sec_w
525 w = ((trace.processes[val][1] - s) * sec_w) 527 w = ((trace.processes[val][1] - s) * sec_w)
526 528
527 #print "proc at %s %s %s %s" % (x, y, w, proc_h) 529 #print("proc at %s %s %s %s" % (x, y, w, proc_h))
528 col = None 530 col = None
529 if task == "do_compile": 531 if task == "do_compile":
530 col = TASK_COLOR_COMPILE 532 col = TASK_COLOR_COMPILE
diff --git a/scripts/pybootchartgui/pybootchartgui/gui.py b/scripts/pybootchartgui/pybootchartgui/gui.py
index 7fedd232df..e1fe915563 100644
--- a/scripts/pybootchartgui/pybootchartgui/gui.py
+++ b/scripts/pybootchartgui/pybootchartgui/gui.py
@@ -13,64 +13,83 @@
13# You should have received a copy of the GNU General Public License 13# You should have received a copy of the GNU General Public License
14# along with pybootchartgui. If not, see <http://www.gnu.org/licenses/>. 14# along with pybootchartgui. If not, see <http://www.gnu.org/licenses/>.
15 15
16import gobject 16import gi
17import gtk 17gi.require_version('Gtk', '3.0')
18import gtk.gdk 18from gi.repository import Gtk as gtk
19import gtk.keysyms 19from gi.repository import Gtk
20from gi.repository import Gdk
21from gi.repository import GObject as gobject
22from gi.repository import GObject
23
20from . import draw 24from . import draw
21from .draw import RenderOptions 25from .draw import RenderOptions
22 26
23class PyBootchartWidget(gtk.DrawingArea): 27class PyBootchartWidget(gtk.DrawingArea, gtk.Scrollable):
24 __gsignals__ = { 28 __gsignals__ = {
25 'expose-event': 'override', 29 'clicked' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, Gdk.Event)),
26 'clicked' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, gtk.gdk.Event)),
27 'position-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_INT, gobject.TYPE_INT)), 30 'position-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_INT, gobject.TYPE_INT)),
28 'set-scroll-adjustments' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gtk.Adjustment, gtk.Adjustment)) 31 'set-scroll-adjustments' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gtk.Adjustment, gtk.Adjustment))
29 } 32 }
30 33
34 hadjustment = GObject.property(type=Gtk.Adjustment,
35 default=Gtk.Adjustment(),
36 flags=GObject.PARAM_READWRITE)
37 hscroll_policy = GObject.property(type=Gtk.ScrollablePolicy,
38 default=Gtk.ScrollablePolicy.MINIMUM,
39 flags=GObject.PARAM_READWRITE)
40 vadjustment = GObject.property(type=Gtk.Adjustment,
41 default=Gtk.Adjustment(),
42 flags=GObject.PARAM_READWRITE)
43 vscroll_policy = GObject.property(type=Gtk.ScrollablePolicy,
44 default=Gtk.ScrollablePolicy.MINIMUM,
45 flags=GObject.PARAM_READWRITE)
46
31 def __init__(self, trace, options, xscale): 47 def __init__(self, trace, options, xscale):
32 gtk.DrawingArea.__init__(self) 48 gtk.DrawingArea.__init__(self)
33 49
34 self.trace = trace 50 self.trace = trace
35 self.options = options 51 self.options = options
36 52
37 self.set_flags(gtk.CAN_FOCUS) 53 self.set_can_focus(True)
38 54
39 self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK) 55 self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK)
40 self.connect("button-press-event", self.on_area_button_press) 56 self.connect("button-press-event", self.on_area_button_press)
41 self.connect("button-release-event", self.on_area_button_release) 57 self.connect("button-release-event", self.on_area_button_release)
42 self.add_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.BUTTON_RELEASE_MASK) 58 self.add_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK)
43 self.connect("motion-notify-event", self.on_area_motion_notify) 59 self.connect("motion-notify-event", self.on_area_motion_notify)
44 self.connect("scroll-event", self.on_area_scroll_event) 60 self.connect("scroll-event", self.on_area_scroll_event)
45 self.connect('key-press-event', self.on_key_press_event) 61 self.connect('key-press-event', self.on_key_press_event)
46 62
47 self.connect('set-scroll-adjustments', self.on_set_scroll_adjustments)
48 self.connect("size-allocate", self.on_allocation_size_changed) 63 self.connect("size-allocate", self.on_allocation_size_changed)
49 self.connect("position-changed", self.on_position_changed) 64 self.connect("position-changed", self.on_position_changed)
50 65
66 self.connect("draw", self.on_draw)
67
51 self.zoom_ratio = 1.0 68 self.zoom_ratio = 1.0
52 self.xscale = xscale 69 self.xscale = xscale
53 self.x, self.y = 0.0, 0.0 70 self.x, self.y = 0.0, 0.0
54 71
55 self.chart_width, self.chart_height = draw.extents(self.options, self.xscale, self.trace) 72 self.chart_width, self.chart_height = draw.extents(self.options, self.xscale, self.trace)
56 self.hadj = None 73 self.our_width, self.our_height = self.chart_width, self.chart_height
57 self.vadj = None 74
58 self.hadj_changed_signal_id = None 75 self.hadj = gtk.Adjustment(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
59 self.vadj_changed_signal_id = None 76 self.vadj = gtk.Adjustment(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
60 77 self.vadj.connect('value-changed', self.on_adjustments_changed)
61 def do_expose_event(self, event): 78 self.hadj.connect('value-changed', self.on_adjustments_changed)
62 cr = self.window.cairo_create() 79
63 80 def bound_vals(self):
64 # set a clip region for the expose event 81 self.x = max(0, self.x)
65 cr.rectangle( 82 self.y = max(0, self.y)
66 event.area.x, event.area.y, 83 self.x = min(self.chart_width - self.our_width, self.x)
67 event.area.width, event.area.height 84 self.y = min(self.chart_height - self.our_height, self.y)
68 ) 85
69 cr.clip() 86 def on_draw(self, darea, cr):
70 self.draw(cr, self.get_allocation()) 87 # set a clip region
71 return False 88 #cr.rectangle(
72 89 # self.x, self.y,
73 def draw(self, cr, rect): 90 # self.chart_width, self.chart_height
91 #)
92 #cr.clip()
74 cr.set_source_rgba(1.0, 1.0, 1.0, 1.0) 93 cr.set_source_rgba(1.0, 1.0, 1.0, 1.0)
75 cr.paint() 94 cr.paint()
76 cr.scale(self.zoom_ratio, self.zoom_ratio) 95 cr.scale(self.zoom_ratio, self.zoom_ratio)
@@ -84,7 +103,7 @@ class PyBootchartWidget(gtk.DrawingArea):
84 103
85 def zoom_image (self, zoom_ratio): 104 def zoom_image (self, zoom_ratio):
86 self.zoom_ratio = zoom_ratio 105 self.zoom_ratio = zoom_ratio
87 self._set_scroll_adjustments (self.hadj, self.vadj) 106 self._set_scroll_adjustments()
88 self.queue_draw() 107 self.queue_draw()
89 108
90 def zoom_to_rect (self, rect): 109 def zoom_to_rect (self, rect):
@@ -122,126 +141,101 @@ class PyBootchartWidget(gtk.DrawingArea):
122 def show_toggled(self, button): 141 def show_toggled(self, button):
123 self.options.app_options.show_all = button.get_property ('active') 142 self.options.app_options.show_all = button.get_property ('active')
124 self.chart_width, self.chart_height = draw.extents(self.options, self.xscale, self.trace) 143 self.chart_width, self.chart_height = draw.extents(self.options, self.xscale, self.trace)
125 self._set_scroll_adjustments(self.hadj, self.vadj) 144 self._set_scroll_adjustments()
126 self.queue_draw() 145 self.queue_draw()
127 146
128 POS_INCREMENT = 100 147 POS_INCREMENT = 100
129 148
130 def on_key_press_event(self, widget, event): 149 def on_key_press_event(self, widget, event):
131 if event.keyval == gtk.keysyms.Left: 150 if event.keyval == Gdk.keyval_from_name("Left"):
132 self.x -= self.POS_INCREMENT/self.zoom_ratio 151 self.x -= self.POS_INCREMENT/self.zoom_ratio
133 elif event.keyval == gtk.keysyms.Right: 152 elif event.keyval == Gdk.keyval_from_name("Right"):
134 self.x += self.POS_INCREMENT/self.zoom_ratio 153 self.x += self.POS_INCREMENT/self.zoom_ratio
135 elif event.keyval == gtk.keysyms.Up: 154 elif event.keyval == Gdk.keyval_from_name("Up"):
136 self.y -= self.POS_INCREMENT/self.zoom_ratio 155 self.y -= self.POS_INCREMENT/self.zoom_ratio
137 elif event.keyval == gtk.keysyms.Down: 156 elif event.keyval == Gdk.keyval_from_name("Down"):
138 self.y += self.POS_INCREMENT/self.zoom_ratio 157 self.y += self.POS_INCREMENT/self.zoom_ratio
139 else: 158 else:
140 return False 159 return False
160 self.bound_vals()
141 self.queue_draw() 161 self.queue_draw()
142 self.position_changed() 162 self.position_changed()
143 return True 163 return True
144 164
145 def on_area_button_press(self, area, event): 165 def on_area_button_press(self, area, event):
146 if event.button == 2 or event.button == 1: 166 if event.button == 2 or event.button == 1:
147 area.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.FLEUR)) 167 window = self.get_window()
168 window.set_cursor(Gdk.Cursor(Gdk.CursorType.FLEUR))
148 self.prevmousex = event.x 169 self.prevmousex = event.x
149 self.prevmousey = event.y 170 self.prevmousey = event.y
150 if event.type not in (gtk.gdk.BUTTON_PRESS, gtk.gdk.BUTTON_RELEASE): 171 if event.type not in (Gdk.EventType.BUTTON_PRESS, Gdk.EventType.BUTTON_RELEASE):
151 return False 172 return False
152 return False 173 return False
153 174
154 def on_area_button_release(self, area, event): 175 def on_area_button_release(self, area, event):
155 if event.button == 2 or event.button == 1: 176 if event.button == 2 or event.button == 1:
156 area.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW)) 177 window = self.get_window()
178 window.set_cursor(Gdk.Cursor(Gdk.CursorType.ARROW))
157 self.prevmousex = None 179 self.prevmousex = None
158 self.prevmousey = None 180 self.prevmousey = None
159 return True 181 return True
160 return False 182 return False
161 183
162 def on_area_scroll_event(self, area, event): 184 def on_area_scroll_event(self, area, event):
163 if event.state & gtk.gdk.CONTROL_MASK: 185 if event.state & Gdk.CONTROL_MASK:
164 if event.direction == gtk.gdk.SCROLL_UP: 186 if event.direction == Gdk.SCROLL_UP:
165 self.zoom_image(self.zoom_ratio * self.ZOOM_INCREMENT) 187 self.zoom_image(self.zoom_ratio * self.ZOOM_INCREMENT)
166 return True 188 return True
167 if event.direction == gtk.gdk.SCROLL_DOWN: 189 if event.direction == Gdk.SCROLL_DOWN:
168 self.zoom_image(self.zoom_ratio / self.ZOOM_INCREMENT) 190 self.zoom_image(self.zoom_ratio / self.ZOOM_INCREMENT)
169 return True 191 return True
170 return False 192 return False
171 193
172 def on_area_motion_notify(self, area, event): 194 def on_area_motion_notify(self, area, event):
173 state = event.state 195 state = event.state
174 if state & gtk.gdk.BUTTON2_MASK or state & gtk.gdk.BUTTON1_MASK: 196 if state & Gdk.ModifierType.BUTTON2_MASK or state & Gdk.ModifierType.BUTTON1_MASK:
175 x, y = int(event.x), int(event.y) 197 x, y = int(event.x), int(event.y)
176 # pan the image 198 # pan the image
177 self.x += (self.prevmousex - x)/self.zoom_ratio 199 self.x += (self.prevmousex - x)/self.zoom_ratio
178 self.y += (self.prevmousey - y)/self.zoom_ratio 200 self.y += (self.prevmousey - y)/self.zoom_ratio
201 self.bound_vals()
179 self.queue_draw() 202 self.queue_draw()
180 self.prevmousex = x 203 self.prevmousex = x
181 self.prevmousey = y 204 self.prevmousey = y
182 self.position_changed() 205 self.position_changed()
183 return True 206 return True
184 207
185 def on_set_scroll_adjustments(self, area, hadj, vadj):
186 self._set_scroll_adjustments (hadj, vadj)
187
188 def on_allocation_size_changed(self, widget, allocation): 208 def on_allocation_size_changed(self, widget, allocation):
189 self.hadj.page_size = allocation.width 209 self.hadj.page_size = allocation.width
190 self.hadj.page_increment = allocation.width * 0.9 210 self.hadj.page_increment = allocation.width * 0.9
191 self.vadj.page_size = allocation.height 211 self.vadj.page_size = allocation.height
192 self.vadj.page_increment = allocation.height * 0.9 212 self.vadj.page_increment = allocation.height * 0.9
213 self.our_width = allocation.width
214 if self.chart_width < self.our_width:
215 self.our_width = self.chart_width
216 self.our_height = allocation.height
217 if self.chart_height < self.our_height:
218 self.our_height = self.chart_height
219 self._set_scroll_adjustments()
193 220
194 def _set_adj_upper(self, adj, upper): 221 def _set_adj_upper(self, adj, upper):
195 changed = False 222
196 value_changed = False 223 if adj.get_upper() != upper:
197 224 adj.set_upper(upper)
198 if adj.upper != upper: 225
199 adj.upper = upper 226 def _set_scroll_adjustments(self):
200 changed = True 227 self._set_adj_upper (self.hadj, self.zoom_ratio * (self.chart_width - self.our_width))
201 228 self._set_adj_upper (self.vadj, self.zoom_ratio * (self.chart_height - self.our_height))
202 max_value = max(0.0, upper - adj.page_size)
203 if adj.value > max_value:
204 adj.value = max_value
205 value_changed = True
206
207 if changed:
208 adj.changed()
209 if value_changed:
210 adj.value_changed()
211
212 def _set_scroll_adjustments(self, hadj, vadj):
213 if hadj == None:
214 hadj = gtk.Adjustment(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
215 if vadj == None:
216 vadj = gtk.Adjustment(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
217
218 if self.hadj_changed_signal_id != None and \
219 self.hadj != None and hadj != self.hadj:
220 self.hadj.disconnect (self.hadj_changed_signal_id)
221 if self.vadj_changed_signal_id != None and \
222 self.vadj != None and vadj != self.vadj:
223 self.vadj.disconnect (self.vadj_changed_signal_id)
224
225 if hadj != None:
226 self.hadj = hadj
227 self._set_adj_upper (self.hadj, self.zoom_ratio * self.chart_width)
228 self.hadj_changed_signal_id = self.hadj.connect('value-changed', self.on_adjustments_changed)
229
230 if vadj != None:
231 self.vadj = vadj
232 self._set_adj_upper (self.vadj, self.zoom_ratio * self.chart_height)
233 self.vadj_changed_signal_id = self.vadj.connect('value-changed', self.on_adjustments_changed)
234 229
235 def on_adjustments_changed(self, adj): 230 def on_adjustments_changed(self, adj):
236 self.x = self.hadj.value / self.zoom_ratio 231 self.x = self.hadj.get_value() / self.zoom_ratio
237 self.y = self.vadj.value / self.zoom_ratio 232 self.y = self.vadj.get_value() / self.zoom_ratio
238 self.queue_draw() 233 self.queue_draw()
239 234
240 def on_position_changed(self, widget, x, y): 235 def on_position_changed(self, widget, x, y):
241 self.hadj.value = x * self.zoom_ratio 236 self.hadj.set_value(x * self.zoom_ratio)
242 self.vadj.value = y * self.zoom_ratio 237 #self.hadj.value_changed()
243 238 self.vadj.set_value(y * self.zoom_ratio)
244PyBootchartWidget.set_set_scroll_adjustments_signal('set-scroll-adjustments')
245 239
246class PyBootchartShell(gtk.VBox): 240class PyBootchartShell(gtk.VBox):
247 ui = ''' 241 ui = '''
@@ -260,7 +254,7 @@ class PyBootchartShell(gtk.VBox):
260 def __init__(self, window, trace, options, xscale): 254 def __init__(self, window, trace, options, xscale):
261 gtk.VBox.__init__(self) 255 gtk.VBox.__init__(self)
262 256
263 self.widget = PyBootchartWidget(trace, options, xscale) 257 self.widget2 = PyBootchartWidget(trace, options, xscale)
264 258
265 # Create a UIManager instance 259 # Create a UIManager instance
266 uimanager = self.uimanager = gtk.UIManager() 260 uimanager = self.uimanager = gtk.UIManager()
@@ -275,12 +269,12 @@ class PyBootchartShell(gtk.VBox):
275 269
276 # Create actions 270 # Create actions
277 actiongroup.add_actions(( 271 actiongroup.add_actions((
278 ('Expand', gtk.STOCK_ADD, None, None, None, self.widget.on_expand), 272 ('Expand', gtk.STOCK_ADD, None, None, None, self.widget2.on_expand),
279 ('Contract', gtk.STOCK_REMOVE, None, None, None, self.widget.on_contract), 273 ('Contract', gtk.STOCK_REMOVE, None, None, None, self.widget2.on_contract),
280 ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, None, self.widget.on_zoom_in), 274 ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, None, self.widget2.on_zoom_in),
281 ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, None, self.widget.on_zoom_out), 275 ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, None, self.widget2.on_zoom_out),
282 ('ZoomFit', gtk.STOCK_ZOOM_FIT, 'Fit Width', None, None, self.widget.on_zoom_fit), 276 ('ZoomFit', gtk.STOCK_ZOOM_FIT, 'Fit Width', None, None, self.widget2.on_zoom_fit),
283 ('Zoom100', gtk.STOCK_ZOOM_100, None, None, None, self.widget.on_zoom_100), 277 ('Zoom100', gtk.STOCK_ZOOM_100, None, None, None, self.widget2.on_zoom_100),
284 )) 278 ))
285 279
286 # Add the actiongroup to the uimanager 280 # Add the actiongroup to the uimanager
@@ -290,29 +284,33 @@ class PyBootchartShell(gtk.VBox):
290 uimanager.add_ui_from_string(self.ui) 284 uimanager.add_ui_from_string(self.ui)
291 285
292 # Scrolled window 286 # Scrolled window
293 scrolled = gtk.ScrolledWindow() 287 scrolled = gtk.ScrolledWindow(self.widget2.hadj, self.widget2.vadj)
294 scrolled.add(self.widget) 288 scrolled.add(self.widget2)
289
290 #scrolled.set_hadjustment()
291 #scrolled.set_vadjustment(self.widget2.vadj)
292 scrolled.set_policy(gtk.PolicyType.ALWAYS, gtk.PolicyType.ALWAYS)
295 293
296 # toolbar / h-box 294 # toolbar / h-box
297 hbox = gtk.HBox(False, 8) 295 hbox = gtk.HBox(False, 8)
298 296
299 # Create a Toolbar 297 # Create a Toolbar
300 toolbar = uimanager.get_widget('/ToolBar') 298 toolbar = uimanager.get_widget('/ToolBar')
301 hbox.pack_start(toolbar, True, True) 299 hbox.pack_start(toolbar, True, True, 0)
302 300
303 if not options.kernel_only: 301 if not options.kernel_only:
304 # Misc. options 302 # Misc. options
305 button = gtk.CheckButton("Show more") 303 button = gtk.CheckButton("Show more")
306 button.connect ('toggled', self.widget.show_toggled) 304 button.connect ('toggled', self.widget2.show_toggled)
307 button.set_active(options.app_options.show_all) 305 button.set_active(options.app_options.show_all)
308 hbox.pack_start (button, False, True) 306 hbox.pack_start (button, False, True, 0)
309 307
310 self.pack_start(hbox, False) 308 self.pack_start(hbox, False, True, 0)
311 self.pack_start(scrolled) 309 self.pack_start(scrolled, True, True, 0)
312 self.show_all() 310 self.show_all()
313 311
314 def grab_focus(self, window): 312 def grab_focus(self, window):
315 window.set_focus(self.widget) 313 window.set_focus(self.widget2)
316 314
317 315
318class PyBootchartWindow(gtk.Window): 316class PyBootchartWindow(gtk.Window):
diff --git a/scripts/pybootchartgui/pybootchartgui/parsing.py b/scripts/pybootchartgui/pybootchartgui/parsing.py
index bcfb2da569..ef2d3d309c 100644
--- a/scripts/pybootchartgui/pybootchartgui/parsing.py
+++ b/scripts/pybootchartgui/pybootchartgui/parsing.py
@@ -267,7 +267,7 @@ def _parse_headers(file):
267 value = line.strip() 267 value = line.strip()
268 headers[last] += value 268 headers[last] += value
269 return headers, last 269 return headers, last
270 return reduce(parse, file.read().decode('utf-8').split('\n'), (defaultdict(str),''))[0] 270 return reduce(parse, file.read().split('\n'), (defaultdict(str),''))[0]
271 271
272def _parse_timed_blocks(file): 272def _parse_timed_blocks(file):
273 """Parses (ie., splits) a file into so-called timed-blocks. A 273 """Parses (ie., splits) a file into so-called timed-blocks. A
@@ -281,7 +281,7 @@ def _parse_timed_blocks(file):
281 return (int(lines[0]), lines[1:]) 281 return (int(lines[0]), lines[1:])
282 except ValueError: 282 except ValueError:
283 raise ParseError("expected a timed-block, but timestamp '%s' is not an integer" % lines[0]) 283 raise ParseError("expected a timed-block, but timestamp '%s' is not an integer" % lines[0])
284 blocks = file.read().decode('utf-8').split('\n\n') 284 blocks = file.read().split('\n\n')
285 return [parse(block) for block in blocks if block.strip() and not block.endswith(' not running\n')] 285 return [parse(block) for block in blocks if block.strip() and not block.endswith(' not running\n')]
286 286
287def _parse_proc_ps_log(writer, file): 287def _parse_proc_ps_log(writer, file):
@@ -577,7 +577,7 @@ def _parse_dmesg(writer, file):
577 processMap['k-boot'] = kernel 577 processMap['k-boot'] = kernel
578 base_ts = False 578 base_ts = False
579 max_ts = 0 579 max_ts = 0
580 for line in file.read().decode('utf-8').split('\n'): 580 for line in file.read().split('\n'):
581 t = timestamp_re.match (line) 581 t = timestamp_re.match (line)
582 if t is None: 582 if t is None:
583# print "duff timestamp " + line 583# print "duff timestamp " + line
@@ -665,7 +665,7 @@ def _parse_pacct(writer, file):
665def _parse_paternity_log(writer, file): 665def _parse_paternity_log(writer, file):
666 parent_map = {} 666 parent_map = {}
667 parent_map[0] = 0 667 parent_map[0] = 0
668 for line in file.read().decode('utf-8').split('\n'): 668 for line in file.read().split('\n'):
669 if not line: 669 if not line:
670 continue 670 continue
671 elems = line.split(' ') # <Child> <Parent> 671 elems = line.split(' ') # <Child> <Parent>
@@ -678,7 +678,7 @@ def _parse_paternity_log(writer, file):
678 678
679def _parse_cmdline_log(writer, file): 679def _parse_cmdline_log(writer, file):
680 cmdLines = {} 680 cmdLines = {}
681 for block in file.read().decode('utf-8').split('\n\n'): 681 for block in file.read().split('\n\n'):
682 lines = block.split('\n') 682 lines = block.split('\n')
683 if len (lines) >= 3: 683 if len (lines) >= 3:
684# print "Lines '%s'" % (lines[0]) 684# print "Lines '%s'" % (lines[0])
@@ -751,7 +751,7 @@ def parse_file(writer, state, filename):
751 if state.filename is None: 751 if state.filename is None:
752 state.filename = filename 752 state.filename = filename
753 basename = os.path.basename(filename) 753 basename = os.path.basename(filename)
754 with open(filename, "rb") as file: 754 with open(filename, "r") as file:
755 return _do_parse(writer, state, filename, file) 755 return _do_parse(writer, state, filename, file)
756 756
757def parse_paths(writer, state, paths): 757def parse_paths(writer, state, paths):