From 3e87a2dbde2d235280b9caa887fdba40af24d10f Mon Sep 17 00:00:00 2001 From: Clark Williams Date: Mon, 13 Aug 2012 10:29:23 -0500 Subject: handle system not having dmidecode python module Signed-off-by: Clark Williams --- rteval/dmi.py | 18 ++++++++++++++++-- 1 file 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) -- cgit