diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dmidecodeXML.py | 62 | ||||
-rw-r--r-- | src/dmidecodemodule.c | 4 | ||||
-rw-r--r-- | src/setup.py | 5 |
3 files changed, 5 insertions, 66 deletions
diff --git a/src/dmidecodeXML.py b/src/dmidecodeXML.py deleted file mode 100644 index 93b4598..0000000 --- a/src/dmidecodeXML.py +++ /dev/null @@ -1,62 +0,0 @@ -import libxml2 -import dmidecode - -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 = dmidecode.xmlapi(query_type='s', - result_type=self.restype, - section=sectname) ) - elif self.restype == DMIXML_DOC: - ret = libxml2.xmlDoc( _obj = dmidecode.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 = dmidecode.xmlapi(query_type='t', - result_type=self.restype, - typeid=tpid)) - elif self.restype == DMIXML_DOC: - ret = libxml2.xmlDoc( _obj = dmidecode.xmlapi(query_type='t', - result_type=self.restype, - typeid=tpid)) - else: - raise TypeError, "Invalid result type value" - - return ret - diff --git a/src/dmidecodemodule.c b/src/dmidecodemodule.c index 846d565..032a189 100644 --- a/src/dmidecodemodule.c +++ b/src/dmidecodemodule.c @@ -676,7 +676,7 @@ void destruct_options(void *ptr) } -PyMODINIT_FUNC initdmidecode(void) +PyMODINIT_FUNC initdmidecodemodule(void) { char *dmiver = NULL; PyObject *module = NULL; @@ -689,7 +689,7 @@ PyMODINIT_FUNC initdmidecode(void) opt = (options *) malloc(sizeof(options)+2); memset(opt, 0, sizeof(options)+2); init(opt); - module = Py_InitModule3((char *)"dmidecode", DMIDataMethods, + module = Py_InitModule3((char *)"dmidecodemodule", DMIDataMethods, "Python extension module for dmidecode"); version = PyString_FromString("3.10.6"); diff --git a/src/setup.py b/src/setup.py index 54b0357..b45775a 100644 --- a/src/setup.py +++ b/src/setup.py @@ -11,7 +11,7 @@ setup( data_files = [ ('share/python-dmidecode', ['src/pymap.xml']) ], ext_modules = [ Extension( - "dmidecode", + "dmidecodemodule", sources = [ "src/dmidecodemodule.c", "src/util.c", @@ -25,5 +25,6 @@ setup( library_dirs = [ "/home/nima/dev-room/projects/dmidecode", "/usr/lib64/python2.5/site-packages"], libraries = [ "util", "xml2", "xml2mod" ] ) - ] + ], + py_modules = [ "dmidecode" ] ) |