Example #1
0
def _initialize_dmi_data():
    """ Initialize _dmi_data unless it already exist and returns it """
    global _dmi_data, _dmi_not_available
    if _dmi_data is None:
        if _dmi_not_available:
            # do not try to initialize it again and again if not available
            return None
        else:
            dmixml = dmidecode.dmidecodeXML()
            dmixml.SetResultType(dmidecode.DMIXML_DOC)
            # Get all the DMI data and prepare a XPath context
            try:
                data = dmixml.QuerySection('all')
                dmi_warn = dmi_warnings()
                if dmi_warn:
                    dmidecode.clear_warnings()
                    log = up2dateLog.initLog()
                    log.log_debug("dmidecode warnings: %s" % dmi_warn)
            except:
                # DMI decode FAIL, this can happend e.g in PV guest
                _dmi_not_available = 1
                dmi_warn = dmi_warnings()
                if dmi_warn:
                    dmidecode.clear_warnings()
                return None
            _dmi_data = data.xpathNewContext()
    return _dmi_data
Example #2
0
def _initialize_dmi_data():
    """ Initialize _dmi_data unless it already exist and returns it """
    global _dmi_data, _dmi_not_available
    if _dmi_data is None:
        if _dmi_not_available:
            # do not try to initialize it again and again if not available
            return None
        else :
            dmixml = dmidecode.dmidecodeXML()
            dmixml.SetResultType(dmidecode.DMIXML_DOC)
            # Get all the DMI data and prepare a XPath context
            try:
                data = dmixml.QuerySection('all')
                dmi_warn = dmi_warnings()
                if dmi_warn:
                    dmidecode.clear_warnings()
                    log = up2dateLog.initLog()
                    log.log_debug("dmidecode warnings: " % dmi_warn)
            except:
                # DMI decode FAIL, this can happend e.g in PV guest
                _dmi_not_available = 1
                dmi_warn = dmi_warnings()
                if dmi_warn:
                    dmidecode.clear_warnings()
                return None
            _dmi_data = data.xpathNewContext()
    return _dmi_data
Example #3
0
 def log_warnings(self, dmidecode):
     dmiwarnings = dmidecode.get_warnings()
     if dmiwarnings:
         log.warn(_("Error reading system DMI information: %s"),
                  dmiwarnings,
                  exc_info=True)
         dmidecode.clear_warnings()
Example #4
0
    def dmi_system(item, data=None):
        if not data:
            data = dmidecode.system()  #@UndefinedVariable
            dmidecode.clear_warnings()  #@UndefinedVariable

        item = item.lower()

        for key, value in data.items():
            if item == key.lower():
                return value.decode('utf-8')
            if isinstance(value, dict) and value:
                value = dmi_system(item, value)
                if value:
                    return value

        return None
Example #5
0
    def dmi_system(item, data=None):
        if not data:
            data = dmidecode.system() #@UndefinedVariable
            dmidecode.clear_warnings() #@UndefinedVariable

        item = item.lower()

        for key, value in data.items():
            if item == key.lower():
                return value.decode('utf-8')
            if isinstance(value, dict) and value:
                value = dmi_system(item, value)
                if value:
                    return value

        return None
Example #6
0
    def dmi_system(item, data=None):
        if not data:
            data = dmidecode.system()
            dmidecode.clear_warnings()

        item = item.lower()

        for key, value in data.iteritems():
            if item == key.lower():
                return value
            if isinstance(value, dict):
                value = dmi_system(item, value)
                if value:
                    return value

        return None
Example #7
0
def ProcessWarnings():
    if not hasattr(dmidecode, 'get_warnings'):
        return

    warnings = dmidecode.get_warnings()
    if warnings == None:
        return

    for warnline in warnings.split('\n'):
        # Ignore these warnings, as they are "valid" if not running as root
        if warnline == '/dev/mem: Permission denied':
            continue
        if warnline == 'No SMBIOS nor DMI entry point found, sorry.':
            continue

        # All other warnings will be printed
        if len(warnline) > 0:
            print "** DMI WARNING ** %s" % warnline

    dmidecode.clear_warnings()
Example #8
0
def ProcessWarnings():

    if not hasattr(dmidecode, 'get_warnings'):
        return

    warnings = dmidecode.get_warnings()
    if warnings == None:
        return

    for warnline in warnings.split('\n'):
        # Ignore these warnings, as they are "valid" if not running as root
        if warnline == '/dev/mem: Permission denied':
            continue
        if warnline == 'No SMBIOS nor DMI entry point found, sorry.':
            continue

        # All other warnings will be printed
        if len(warnline) > 0:
            print "** DMI WARNING ** %s" % warnline

    dmidecode.clear_warnings()
Example #9
0
# this does not change, we can cache it
_dmi_data = None
_dmi_not_available = 0


def dmi_warnings():
    if not hasattr(dmidecode, 'get_warnings'):
        return None

    return dmidecode.get_warnings()


dmi_warn = dmi_warnings()
if dmi_warn:
    dmidecode.clear_warnings()
    log = up2dateLog.initLog()
    log.log_debug("Warnings collected during dmidecode import: %s" % dmi_warn)


def _initialize_dmi_data():
    """ Initialize _dmi_data unless it already exist and returns it """
    global _dmi_data, _dmi_not_available
    if _dmi_data is None:
        if _dmi_not_available:
            # do not try to initialize it again and again if not available
            return None
        else:
            dmixml = dmidecode.dmidecodeXML()
            dmixml.SetResultType(dmidecode.DMIXML_DOC)
            # Get all the DMI data and prepare a XPath context
 def log_warnings(self):
     dmiwarnings = dmidecode.get_warnings()
     if dmiwarnings:
         log.warn(_("Error reading system DMI information: %s"), dmiwarnings)
         dmidecode.clear_warnings()
Example #11
0
except ImportError:
    subscription_manager_available = False

# this does not change, we can cache it
_dmi_data           = None
_dmi_not_available  = 0

def dmi_warnings():
    if not hasattr(dmidecode, 'get_warnings'):
        return None

    return dmidecode.get_warnings()

dmi_warn = dmi_warnings()
if dmi_warn:
    dmidecode.clear_warnings()
    log = up2dateLog.initLog()
    log.log_debug("Warnings collected during dmidecode import: %s" % dmi_warn)

def _initialize_dmi_data():
    """ Initialize _dmi_data unless it already exist and returns it """
    global _dmi_data, _dmi_not_available
    if _dmi_data is None:
        if _dmi_not_available:
            # do not try to initialize it again and again if not available
            return None
        else :
            dmixml = dmidecode.dmidecodeXML()
            dmixml.SetResultType(dmidecode.DMIXML_DOC)
            # Get all the DMI data and prepare a XPath context
            try:
Example #12
0
 def log_warnings(self, dmidecode):
     dmiwarnings = dmidecode.get_warnings()
     if dmiwarnings:
         log.warning(f"Warnings while reading system DMI information:\n{dmiwarnings}")
         dmidecode.clear_warnings()
Example #13
0
def print_warnings():
    warn = dmidecode.get_warnings()
    if warn:
        print("### WARNING: %s" % warn)
        dmidecode.clear_warnings()
Example #14
0
def print_warnings():
        "Simple function, dumping out warnings with a prefix if warnings are found and clearing warning buffer"
        warn = dmidecode.get_warnings()
        if warn:
              print("### WARNING: %s" % warn)
              dmidecode.clear_warnings()
Example #15
0
    ========== ============
    Parameter  Description
    ========== ============
    item       Path to the item to decode.
    data       Optional external data to parse.
    ========== ============

    ``Return``: String
    """
    return None


# Re-define dmi_system depending on capabilities
try:
    import dmidecode
    dmidecode.clear_warnings()  #@UndefinedVariable

    def dmi_system(item, data=None):
        if not data:
            data = dmidecode.system()  #@UndefinedVariable
            dmidecode.clear_warnings()  #@UndefinedVariable

        item = item.lower()

        for key, value in data.items():
            if item == key.lower():
                return value.decode('utf-8')
            if isinstance(value, dict) and value:
                value = dmi_system(item, value)
                if value:
                    return value
Example #16
0
    ========== ============
    Parameter  Description
    ========== ============
    item       Path to the item to decode.
    data       Optional external data to parse.
    ========== ============

    ``Return``: String
    """
    return None

# Re-define dmi_system depending on capabilities
try:
    import dmidecode
    dmidecode.clear_warnings() #@UndefinedVariable

    def dmi_system(item, data=None):
        if not data:
            data = dmidecode.system() #@UndefinedVariable
            dmidecode.clear_warnings() #@UndefinedVariable

        item = item.lower()

        for key, value in data.items():
            if item == key.lower():
                return value.decode('utf-8')
            if isinstance(value, dict) and value:
                value = dmi_system(item, value)
                if value:
                    return value