diff options
author | Clark Williams <williams@redhat.com> | 2012-08-13 10:29:23 -0500 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2012-08-13 10:29:23 -0500 |
commit | 3e87a2dbde2d235280b9caa887fdba40af24d10f (patch) | |
tree | 485eb26e4e3addfbd0c772fe25c904d452d2d199 | |
parent | 20083c69051551153657db2fa07d8aa0f5cc341d (diff) | |
download | rteval-3e87a2dbde2d235280b9caa887fdba40af24d10f.tar.gz rteval-3e87a2dbde2d235280b9caa887fdba40af24d10f.tar.xz rteval-3e87a2dbde2d235280b9caa887fdba40af24d10f.zip |
handle system not having dmidecode python module
Signed-off-by: Clark Williams <williams@redhat.com>
-rw-r--r-- | rteval/dmi.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/rteval/dmi.py b/rteval/dmi.py index 1c3229e..d317c3c 100644 --- a/rteval/dmi.py +++ b/rteval/dmi.py @@ -31,10 +31,19 @@ sys.pathconf = "." import xmlout import libxml2 import libxslt -import dmidecode + +try: + import dmidecode +except: + class dmidecode(object): + fake = 1 + def __init__(self): + pass + def ProcessWarnings(): - if not hasattr(dmidecode, 'get_warnings'): + + if hasattr(dmidecode, "fake") or not hasattr(dmidecode, 'get_warnings'): return warnings = dmidecode.get_warnings() @@ -63,6 +72,9 @@ class DMIinfo(object): self.smbios = None self.sharedir = config.installdir + if hasattr(dmidecode, "fake"): + return + self.dmixml = dmidecode.dmidecodeXML() self.smbios = dmidecode.dmi.replace('SMBIOS ', '').replace(' present', '') @@ -79,6 +91,8 @@ class DMIinfo(object): raise RuntimeError, 'Could not locate XSLT template for DMI data (%s)' % fname def genxml(self, xml): + if hasattr(dmidecode, "fake"): + return self.dmixml.SetResultType(dmidecode.DMIXML_DOC) resdoc = self.xsltparser.applyStylesheet(self.dmixml.QuerySection('all'), None) node = resdoc.getRootElement().copyNode(1) |