From c6935aeff23ccd02d4f236dedf86f108c4df853b Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Wed, 26 Sep 2007 17:26:03 -0400 Subject: Refine the bad hardware checker -- this time it detects my potentially exploding (but now ruled safe) battery correctly. --- modules/hardware.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/hardware.py b/modules/hardware.py index 7c6deb4..5366b78 100755 --- a/modules/hardware.py +++ b/modules/hardware.py @@ -3,6 +3,7 @@ ## ## Hardware profiler plugin ## requires the "smolt" client package be installed +## but also relies on lspci for some things ## ## Copyright 2007, Red Hat, Inc ## Michael DeHaan @@ -23,6 +24,7 @@ sys.path.append("/usr/share/smolt/client") import smolt # our modules +import sub_process from modules import func_module # ================================= @@ -30,10 +32,38 @@ from modules import func_module class HardwareModule(func_module.FuncModule): def __init__(self): self.methods = { - "info": self.info + "info" : self.info, + "hal_info" : self.hal_info } func_module.FuncModule.__init__(self) + def hal_info(self): + """ + Returns the output of lshal, but split up into seperate devices + for easier parsing. Each device is a entry in the return hash. + """ + + cmd = sub_process.Popen(["/usr/bin/lshal"],shell=False,stdout=sub_process.PIPE) + data = cmd.communicate()[0] + + data = data.split("\n") + + results = {} + current = "" + label = data[0] + for d in data: + if d == '': + results[label] = current + current = "" + label = "" + else: + if label == "": + label = d + current = current + d + + return results + + def info(self,with_devices=True): """ Returns a struct of hardware information. By default, this pulls down -- cgit