table.add_row(Row([Column("Installed"), Column(parsesize(ram_b))]))
raw_mem = util.readlog(config.prefs['logs']['meminfo'])
- total_regex = re.compile("(MemTotal:\s*| kB)+")
- free_regex = re.compile("MemFree:\s*")
+ line_regex = re.compile("^Mem(\w+):\s*(\d*)\s*kB$")
for line in raw_mem.splitlines():
- matches = re.findall("^Mem(\w+):\s*(\d*)\s*kB$", line)
+
+ matches = line_regex.findall(line)
+
if len(matches) > 0:
logger.debug("Detected {0} memory of {1} kB".format(matches[0][0].lower(), matches[0][1]))
table.add_row(Row([Column(matches[0][0]), Column(parsesize(float(matches[0][1])*1000))]))
-# if "Mem" in line:
-# total = line_regex.sub("", line, 1)
-# processor = proc_regex.sub("", processor)
-# if not processor in proc_data.items:
-# proc_data.items.append(processor)
-# else:
-# logger.debug("Found duplicate entry (perhaps multiple cores?) for {0}".format(processor))
-# if len(proc_data.items) > 0:
-# section.append_data(proc_data)
-# else:
-# logger.warning("Failed to find processor data")
table.align_column(0, "right")
section.append_table(table)