PHP 8.2.30
Preview: dmidecode.py Size: 3.38 KB
//lib64/python3.6/site-packages/dmidecode.py

#
#   dmidecode.py
#   Module front-end for the python-dmidecode module.
#
#   Copyright 2009      David Sommerseth <davids@redhat.com>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#
#   For the avoidance of doubt the "preferred form" of this code is one which
#   is in an open unpatent encumbered format. Where cryptographic key signing
#   forms part of the process of creating an executable the information
#   including keys needed to generate an equivalently functional executable
#   are deemed to be part of the source code.
#

import libxml2
from dmidecodemod import *

DMIXML_NODE='n'
DMIXML_DOC='d'

class dmidecodeXML:
    "Native Python API for retrieving dmidecode information as XML"

    def __init__(self):
        self.restype = DMIXML_NODE;

    def SetResultType(self, type):
        """
        Sets the result type of queries.  The value can be DMIXML_NODE or DMIXML_DOC,
        which will return an libxml2::xmlNode or libxml2::xmlDoc object, respectively
        """

        if type == DMIXML_NODE:
            self.restype = DMIXML_NODE
        elif type == DMIXML_DOC:
            self.restype = DMIXML_DOC
        else:
            raise TypeError("Invalid result type value")
        return True

    def QuerySection(self, sectname):
        """
        Queries the DMI data structure for a given section name.  A section
        can often contain several DMI type elements
        """
        if self.restype == DMIXML_NODE:
            ret = libxml2.xmlNode( _obj = xmlapi(query_type='s',
                                                           result_type=self.restype,
                                                           section=sectname) )
        elif self.restype == DMIXML_DOC:
            ret = libxml2.xmlDoc( _obj = xmlapi(query_type='s',
                                                          result_type=self.restype,
                                                          section=sectname) )
        else:
            raise TypeError("Invalid result type value")

        return ret


    def QueryTypeId(self, tpid):
        """
        Queries the DMI data structure for a specific DMI type.
        """
        if self.restype == DMIXML_NODE:
            ret = libxml2.xmlNode( _obj = xmlapi(query_type='t',
                                                           result_type=self.restype,
                                                           typeid=tpid))
        elif self.restype == DMIXML_DOC:
            ret = libxml2.xmlDoc( _obj = xmlapi(query_type='t',
                                                          result_type=self.restype,
                                                          typeid=tpid))
        else:
            raise TypeError("Invalid result type value")

        return ret

Directory Contents

Dirs: 23 × Files: 27

Name Size Perms Modified Actions
cffi DIR
- drwxr-xr-x 2024-03-03 19:12:32
Edit Download
- drwxr-xr-x 2024-03-03 19:12:32
Edit Download
- drwxr-xr-x 2025-08-28 15:33:17
Edit Download
- drwxr-xr-x 2025-08-28 15:33:17
Edit Download
dbus DIR
- drwxr-xr-x 2024-03-03 19:11:33
Edit Download
- drwxr-xr-x 2024-03-03 19:11:33
Edit Download
gi DIR
- drwxr-xr-x 2024-03-03 19:11:33
Edit Download
gpg DIR
- drwxr-xr-x 2024-06-15 07:03:57
Edit Download
hawkey DIR
- drwxr-xr-x 2025-01-30 08:10:23
Edit Download
libcomps DIR
- drwxr-xr-x 2024-03-03 19:12:31
Edit Download
- drwxr-xr-x 2024-03-03 19:12:31
Edit Download
libdnf DIR
- drwxr-xr-x 2025-01-30 08:10:22
Edit Download
librepo DIR
- drwxr-xr-x 2024-06-15 07:05:43
Edit Download
- drwxr-xr-x 2024-03-03 19:12:32
Edit Download
psutil DIR
- drwxr-xr-x 2024-08-02 15:10:14
Edit Download
- drwxr-xr-x 2024-08-02 15:10:14
Edit Download
- drwxr-xr-x 2024-03-03 19:11:33
Edit Download
- drwxr-xr-x 2026-03-19 07:09:32
Edit Download
rpm DIR
- drwxr-xr-x 2024-12-19 08:03:36
Edit Download
selinux DIR
- drwxr-xr-x 2026-02-12 08:00:52
Edit Download
systemd DIR
- drwxr-xr-x 2024-03-03 19:12:27
Edit Download
yaml DIR
- drwxr-xr-x 2024-03-03 22:15:44
Edit Download
- drwxr-xr-x 2026-03-24 13:15:18
Edit Download
3.38 KB lrw-r--r-- 2022-11-17 05:51:28
Edit Download
218.24 KB lrwxr-xr-x 2023-03-31 15:12:53
Edit Download
14.89 KB lrw-r--r-- 2016-06-07 10:04:14
Edit Download
2.21 KB lrw-r--r-- 2024-04-06 12:29:29
Edit Download
337.73 KB lrw-r--r-- 2017-10-30 07:39:09
Edit Download
428.34 KB lrwxr-xr-x 2025-08-06 13:59:35
Edit Download
20.05 KB lrwxr-xr-x 2019-11-13 15:07:37
Edit Download
261 B lrw-r--r-- 2026-02-24 23:35:24
Edit Download
371.64 KB lrwxr-xr-x 2026-02-24 23:48:44
Edit Download
806 B lrw-r--r-- 2020-08-19 08:40:47
Edit Download
24.28 KB lrwxr-xr-x 2026-03-03 12:26:46
Edit Download
310 B lrw-r--r-- 2023-03-31 15:12:53
Edit Download
1.48 KB lrw-r--r-- 2019-10-28 09:06:07
Edit Download
119 B lrw-r--r-- 2018-12-23 21:37:14
Edit Download
222 B lrw-r--r-- 2024-12-17 04:11:04
Edit Download
221 B lrw-r--r-- 2026-02-10 14:26:37
Edit Download
30.40 KB lrw-r--r-- 2020-06-01 14:11:17
Edit Download
586 B lrw-r--r-- 2019-11-14 17:15:28
Edit Download
68.28 KB lrw-r--r-- 2025-07-28 13:31:45
Edit Download
100.70 KB lrw-r--r-- 2025-07-28 13:31:45
Edit Download
176.75 KB lrwxr-xr-x 2023-10-14 23:41:10
Edit Download
176.71 KB lrwxr-xr-x 2019-11-14 17:08:13
Edit Download
12.50 KB lrwxr-xr-x 2019-11-14 17:08:13
Edit Download
312.57 KB lrwxr-xr-x 2026-02-10 14:26:37
Edit Download
44.27 KB lrwxr-xr-x 2020-06-01 14:11:18
Edit Download
193.47 KB lrwxr-xr-x 2025-07-28 13:31:47
Edit Download
244.70 KB lrwxr-xr-x 2019-10-28 09:06:07
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).