Package: bootchart2 / 0.14.4-3

0004-pybootchartgui-be-more-tolerant-when-parsing-proc_me.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
From 62a80e0848bf3f5119a32bb82c7e141bd49d5e11 Mon Sep 17 00:00:00 2001
From: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Date: Fri, 17 Aug 2012 18:02:12 +0200
Subject: [PATCH] pybootchartgui: be more tolerant when parsing
 proc_meminfo.log

waasdorp reports in bug #40 that we are raising an exception if
a line in proc_meminfo.log is not well formed.
He is right because we were trying to access matches of a regexp
that did not match.

That is obviously silly but it is also silly to stop processing
all the data if a line is wrong, even a line that we are not
interested in it. Instead ignore the line and skip the sample
if it is not valid.

Example of broken line:

Shmem:

While at it remove an unused variable
---
 pybootchartgui/parsing.py |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/pybootchartgui/parsing.py b/pybootchartgui/parsing.py
index 0c54884..845b3ae 100644
--- a/pybootchartgui/parsing.py
+++ b/pybootchartgui/parsing.py
@@ -453,8 +453,6 @@ def _parse_proc_meminfo_log(file):
     Parse file for global memory statistics.
     The format of relevant lines should be: ^key: value( unit)?
     """
-    used_values = ('MemTotal', 'MemFree', 'Buffers', 'Cached', 'SwapTotal', 'SwapFree',)
-
     mem_stats = []
     meminfo_re = re.compile(r'([^ \t:]+):\s*(\d+).*')
 
@@ -463,9 +461,8 @@ def _parse_proc_meminfo_log(file):
 
         for line in lines:
             match = meminfo_re.match(line)
-            if not match:
-                raise ParseError("Invalid meminfo line \"%s\"" % match.groups(0))
-            sample.add_value(match.group(1), int(match.group(2)))
+            if match:
+                sample.add_value(match.group(1), int(match.group(2)))
 
         if sample.valid():
             mem_stats.append(sample)
-- 
1.7.10.4