summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-12-19 11:56:39 +0000
committernima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-12-19 11:56:39 +0000
commitb007b775afdba38cdc3430ec9c909324d3522fb4 (patch)
treec7ed48a665fe3a8fb44ca6c7af72386db2d16ed3 /src
parenteaa8d27476769e2b65e92d6b0010356ca7cc4f2e (diff)
downloadpython-dmidecode-b007b775afdba38cdc3430ec9c909324d3522fb4.tar.gz
python-dmidecode-b007b775afdba38cdc3430ec9c909324d3522fb4.tar.xz
python-dmidecode-b007b775afdba38cdc3430ec9c909324d3522fb4.zip
Test for write permission prior to write attempts.
git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@123 abc39116-655e-4be6-ad55-d661dc543056
Diffstat (limited to 'src')
-rw-r--r--src/dmidecodemodule.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/dmidecodemodule.c b/src/dmidecodemodule.c
index 7871a89..8aec347 100644
--- a/src/dmidecodemodule.c
+++ b/src/dmidecodemodule.c
@@ -158,10 +158,10 @@ static PyObject* dmidecode_get_type(PyObject *self, PyObject *args) {
}
static PyObject* dmidecode_dump(PyObject *self, PyObject *args) {
- if(dump(PyString_AS_STRING(opt.dumpfile)))
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
+ if(access(opt.dumpfile, W_OK) == 0)
+ if(dump(PyString_AS_STRING(opt.dumpfile)))
+ Py_RETURN_TRUE;
+ Py_RETURN_FALSE;
}
static PyObject* dmidecode_get_dev(PyObject *self, PyObject *null) {
@@ -175,9 +175,7 @@ static PyObject* dmidecode_set_dev(PyObject *self, PyObject *arg) {
opt.dumpfile = arg;
Py_INCREF(opt.dumpfile);
Py_RETURN_TRUE;
- } else {
- Py_RETURN_FALSE;
- }
+ } else Py_RETURN_FALSE;
//PyErr_Occurred()
}
@@ -185,7 +183,7 @@ static PyObject* dmidecode_set_dev(PyObject *self, PyObject *arg) {
PyMethodDef DMIDataMethods[] = {
{ (char *)"dump", dmidecode_dump, METH_NOARGS, (char *)"Dump dmidata to set file" },
- { (char *)"get_dev", dmidecode_get_dev, METH_NOARGS, (char *)"Set an alternative memory device file" },
+ { (char *)"get_dev", dmidecode_get_dev, METH_NOARGS, (char *)"Get an alternative memory device file" },
{ (char *)"set_dev", dmidecode_set_dev, METH_O, (char *)"Set an alternative memory device file" },
{ (char *)"bios", dmidecode_get_bios, METH_VARARGS, (char *)"BIOS Data" },
@@ -197,6 +195,7 @@ PyMethodDef DMIDataMethods[] = {
{ (char *)"cache", dmidecode_get_cache, METH_VARARGS, (char *)"Cache Data" },
{ (char *)"connector", dmidecode_get_connector, METH_VARARGS, (char *)"Connector Data" },
{ (char *)"slot", dmidecode_get_slot, METH_VARARGS, (char *)"Slot Data" },
+
{ (char *)"type", dmidecode_get_type, METH_VARARGS, (char *)"By Type" },
{ NULL, NULL, 0, NULL }
};