From 20c1782f7865b5f96b1650a65097a0e2bdd1241e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 7 Mar 2014 00:16:52 +0100 Subject: fix and demo cpuonline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/plugins/cpuonline.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/cpuonline.py b/src/plugins/cpuonline.py index 75e8bed..8b42f66 100644 --- a/src/plugins/cpuonline.py +++ b/src/plugins/cpuonline.py @@ -45,8 +45,10 @@ class CPUOnline: for filename in ('offline', 'online', 'possible', 'present'): with open('/sys/devices/system/cpu/online', 'rb') as file: data.append(file.read()) + data = [x.decode('utf-8', 'replace').replace('\n', ' ').replace(',', ' ') for x in data] - data = [reduce(lambda x, y : x + y, map(expand, x.split(' '))) for x in data] + data = [map(expand, filter(lambda item : not item == '', x.split(' '))) for x in data] + data = [reduce(lambda x, y : x + y, list(x)) for x in data] (self.offline, self.online, self.possible, self.present) = data -- cgit v1.2.3-70-g09d2