diff options
author | Michael DeHaan <mdehaan@mdehaan.rdu.redhat.com> | 2007-09-26 17:26:03 -0400 |
---|---|---|
committer | Michael DeHaan <mdehaan@mdehaan.rdu.redhat.com> | 2007-09-26 17:26:03 -0400 |
commit | c6935aeff23ccd02d4f236dedf86f108c4df853b (patch) | |
tree | 2f54c48c0e84d37a498c09a7275a9f9fb4ce528c /modules | |
parent | 484c9dba767b8a9b1e907d5e4179951ca3f1f2f7 (diff) | |
download | third_party-func-c6935aeff23ccd02d4f236dedf86f108c4df853b.tar.gz third_party-func-c6935aeff23ccd02d4f236dedf86f108c4df853b.tar.xz third_party-func-c6935aeff23ccd02d4f236dedf86f108c4df853b.zip |
Refine the bad hardware checker -- this time it detects my potentially exploding (but now ruled safe)
battery correctly.
Diffstat (limited to 'modules')
-rwxr-xr-x | modules/hardware.py | 32 |
1 files changed, 31 insertions, 1 deletions
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 <mdehaan@redhat.com> @@ -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 |