Package: bootchart2 / 0.14.4-3

0001-pybootchartgui-fix-parsing-of-non-ascii-bytes-in-log.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From 9a7ff9823ae8562e11094a5a7155af067733ae95 Mon Sep 17 00:00:00 2001
From: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Date: Sun, 17 Jun 2012 12:53:42 +0200
Subject: [PATCH] pybootchartgui: fix parsing of non-ascii bytes in logs

It looks like the days of ascii logs is gone so decode all the
files we read as utf-8. Fix #38.
---
 pybootchartgui/parsing.py |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Index: bootchart2-0.14.4/pybootchartgui/parsing.py
===================================================================
--- bootchart2-0.14.4.orig/pybootchartgui/parsing.py	2012-09-08 13:13:36.000000000 +0100
+++ bootchart2-0.14.4/pybootchartgui/parsing.py	2012-09-08 13:13:36.000000000 +0100
@@ -228,7 +228,7 @@
             value = line.strip()
         headers[last] += value
         return headers, last
-    return reduce(parse, file.read().decode().split('\n'), (defaultdict(str),''))[0]
+    return reduce(parse, file.read().decode('utf-8').split('\n'), (defaultdict(str),''))[0]
 
 def _parse_timed_blocks(file):
     """Parses (ie., splits) a file into so-called timed-blocks. A
@@ -242,7 +242,7 @@
             return (int(lines[0]), lines[1:])
         except ValueError:
             raise ParseError("expected a timed-block, but timestamp '%s' is not an integer" % lines[0])
-    blocks = file.read().decode().split('\n\n')
+    blocks = file.read().decode('utf-8').split('\n\n')
     return [parse(block) for block in blocks if block.strip() and not block.endswith(' not running\n')]
 
 def _parse_proc_ps_log(writer, file):
@@ -491,7 +491,7 @@
     processMap['k-boot'] = kernel
     base_ts = False
     max_ts = 0
-    for line in file.read().decode().split('\n'):
+    for line in file.read().decode('utf-8').split('\n'):
         t = timestamp_re.match (line)
         if t is None:
 #                       print "duff timestamp " + line
@@ -579,7 +579,7 @@
 def _parse_paternity_log(writer, file):
     parent_map = {}
     parent_map[0] = 0
-    for line in file.read().decode().split('\n'):
+    for line in file.read().decode('utf-8').split('\n'):
         elems = line.split(' ') # <Child> <Parent>
         if len (elems) >= 2:
 #                       print "paternity of %d is %d" % (int(elems[0]), int(elems[1]))
@@ -590,7 +590,7 @@
 
 def _parse_cmdline_log(writer, file):
     cmdLines = {}
-    for block in file.read().decode().split('\n\n'):
+    for block in file.read().decode('utf-8').split('\n\n'):
         lines = block.split('\n')
         if len (lines) >= 3:
 #                       print "Lines '%s'" % (lines[0])