summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-09-04 02:26:09 +0000
committernima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-09-04 02:26:09 +0000
commitb3880a3305dcdd866638202b9da95cd99f06b085 (patch)
tree142d2cb2bc06d47be73276ea2ca5e14d6ac532f7
parent1fea35ea0c1635e080028c914b88849c721764e6 (diff)
downloadpython-dmidecode-b3880a3305dcdd866638202b9da95cd99f06b085.tar.gz
python-dmidecode-b3880a3305dcdd866638202b9da95cd99f06b085.tar.xz
python-dmidecode-b3880a3305dcdd866638202b9da95cd99f06b085.zip
Work on CPU details - seemed to been a bug with appending to a string rather
than rewriting it. git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@67 abc39116-655e-4be6-ad55-d661dc543056
-rw-r--r--dmidecode.c4
-rw-r--r--dmidecodemodule.c5
-rwxr-xr-xexample.py9
3 files changed, 15 insertions, 3 deletions
diff --git a/dmidecode.c b/dmidecode.c
index 3200d63..e10b931 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -1024,8 +1024,8 @@ static PyObject *dmi_processor_voltage(u8 code) {
const char *dmi_processor_frequency(u8 *p, char *_) {
u16 code = WORD(p);
- if(code) catsprintf(_, "%u MHz", code);
- else catsprintf(_, "Unknown");
+ if(code) sprintf(_, "%u MHz", code);
+ else sprintf(_, "Unknown");
return _;
}
static PyObject *dmi_processor_frequency_py(u8 *p, char *_) {
diff --git a/dmidecodemodule.c b/dmidecodemodule.c
index 5b6f63a..6e9cfe5 100644
--- a/dmidecodemodule.c
+++ b/dmidecodemodule.c
@@ -120,6 +120,10 @@ static PyObject* dmidecode_get_memory(PyObject *self, PyObject *args) { return d
static PyObject* dmidecode_get_cache(PyObject *self, PyObject *args) { return dmidecode_get(self, "cache"); }
static PyObject* dmidecode_get_connector(PyObject *self, PyObject *args) { return dmidecode_get(self, "connector"); }
static PyObject* dmidecode_get_slot(PyObject *self, PyObject *args) { return dmidecode_get(self, "slot"); }
+static PyObject* dmidecode_get_type(PyObject *self, PyObject *args) {
+ fprintf(stderr, "%s\n", PyString_AsString(args));
+ return dmidecode_get(self, PyString_AsString(args));
+}
PyMethodDef DMIDataMethods[] = {
{ "bios", dmidecode_get_bios, METH_VARARGS, "BIOS Data" },
@@ -131,6 +135,7 @@ PyMethodDef DMIDataMethods[] = {
{ "cache", dmidecode_get_cache, METH_VARARGS, "Cache Data" },
{ "connector", dmidecode_get_connector, METH_VARARGS, "Connector Data" },
{ "slot", dmidecode_get_slot, METH_VARARGS, "Slot Data" },
+ { "type", dmidecode_get_type, METH_VARARGS, "By Type" },
{ NULL, NULL, 0, NULL }
};
diff --git a/example.py b/example.py
index f7370bd..bfea140 100755
--- a/example.py
+++ b/example.py
@@ -2,7 +2,7 @@
import dmidecode
import sys
from pprint import pprint
-print "*** bios ***"; pprint(dmidecode.bios())
+#print "*** bios ***"; pprint(dmidecode.bios())
#print "*** system ***\n", pprint(dmidecode.system())
#print "*** baseboard ***\n"; pprint(dmidecode.baseboard())
#print "*** chassis ***\n"; pprint(dmidecode.chassis())
@@ -11,3 +11,10 @@ print "*** bios ***"; pprint(dmidecode.bios())
#print "*** cache ***\n"; pprint(dmidecode.cache())
#print "*** connector ***\n"; pprint(dmidecode.connector())
#print "*** slot ***\n"; pprint(dmidecode.slot())
+#
+#for v in dmidecode.memory().values():
+# if type(v) == dict and v['dmi_type'] == 17:
+# print v['data']['Size'],
+#print ""
+
+print dmidecode.type('17')