diff options
author | Matt Wilson <msw@redhat.com> | 1999-08-24 04:16:39 +0000 |
---|---|---|
committer | Matt Wilson <msw@redhat.com> | 1999-08-24 04:16:39 +0000 |
commit | aec3771a05af87733b30d1552d78a9a322821ac8 (patch) | |
tree | 5974b1147da5231a410d06057542709bd2f6783b | |
parent | 097a43a58ccd8827c68df5ad49bde00a91c3e3a0 (diff) | |
download | anaconda-aec3771a05af87733b30d1552d78a9a322821ac8.tar.gz anaconda-aec3771a05af87733b30d1552d78a9a322821ac8.tar.xz anaconda-aec3771a05af87733b30d1552d78a9a322821ac8.zip |
RPM error callbacks, don't report errors on 'cant make directory'
-rw-r--r-- | rpmmodule/rpmmodule.c | 54 | ||||
-rw-r--r-- | todo.py | 10 |
2 files changed, 62 insertions, 2 deletions
diff --git a/rpmmodule/rpmmodule.c b/rpmmodule/rpmmodule.c index fcc6b3530..8cf30b6a5 100644 --- a/rpmmodule/rpmmodule.c +++ b/rpmmodule/rpmmodule.c @@ -42,6 +42,8 @@ static PyObject * rpmHeaderFromFile(PyObject * self, PyObject * args); static PyObject * archScore(PyObject * self, PyObject * args); static PyObject * rpmHeaderFromFD(PyObject * self, PyObject * args); static PyObject * findUpgradeSet(PyObject * self, PyObject * args); +static PyObject * errorSetCallback (PyObject * self, PyObject * args); +static PyObject * errorString (PyObject * self, PyObject * args); static PyObject * rpmtransCreate(PyObject * self, PyObject * args); static PyObject * rpmtransAdd(rpmtransObject * s, PyObject * args); @@ -64,6 +66,8 @@ static PyMethodDef rpmModuleMethods[] = { { "opendb", (PyCFunction) rpmOpenDB, METH_VARARGS, NULL }, { "readHeaderListFromFD", (PyCFunction) rpmHeaderFromFD, METH_VARARGS, NULL }, { "readHeaderListFromFile", (PyCFunction) rpmHeaderFromFile, METH_VARARGS, NULL }, + { "errorSetCallback", (PyCFunction) errorSetCallback, METH_VARARGS, NULL }, + { "errorString", (PyCFunction) errorString, METH_VARARGS, NULL }, { NULL } } ; @@ -513,6 +517,56 @@ static PyObject * rpmHeaderFromFile(PyObject * self, PyObject * args) { return list; } +static PyObject * errorCB = NULL, * errorData = NULL; + +static void errorcb (void) +{ + PyObject * result, * args = NULL; + + if (errorData) + args = Py_BuildValue("(O)", errorData); + + result = PyEval_CallObject(errorCB, args); + Py_XDECREF(args); + + if (result == NULL) { + PyErr_Print(); + PyErr_Clear(); + } + Py_DECREF (result); +} + +static PyObject * errorSetCallback (PyObject * self, PyObject * args) { + if (errorCB != NULL) { + Py_DECREF (errorCB); + errorCB = NULL; + } + + if (errorData != NULL) { + Py_DECREF (errorData); + errorData = NULL; + } + + if (!PyArg_ParseTuple(args, "O|O", &errorCB, &errorData)) return NULL; + + if (!PyCallable_Check (errorCB)) { + PyErr_SetString(PyExc_TypeError, "parameter must be callable"); + return NULL; + } + + Py_INCREF (errorCB); + Py_XINCREF (errorData); + + rpmErrorSetCallback (errorcb); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * errorString (PyObject * self, PyObject * args) { + return PyString_FromString(rpmErrorString ()); +} + static PyObject * rpmHeaderFromPackage(PyObject * self, PyObject * args) { hdrObject * h; Header header; @@ -807,6 +807,9 @@ class ToDo: for package in packages: self.hdList[package[rpm.RPMTAG_NAME]].selected = 1 win.pop () + + def rpmError (self): + todo.instLog.write (rpm.errorString () + "\n") def doInstall(self): # make sure we have the header list and comps file @@ -831,8 +834,9 @@ class ToDo: try: os.mkdir(self.instPath + i) except os.error, (errno, msg): - self.intf.messageWindow("Error", "Error making directory %s: %s" % (i, msg)) - + # self.intf.messageWindow("Error", "Error making directory %s: %s" % (i, msg)) + pass + db = rpm.opendb(1, self.instPath) ts = rpm.TransactionSet(self.instPath, db) @@ -890,6 +894,8 @@ class ToDo: else: pass + rpm.errorSetCallback (self.rpmError) + # XXX FIXME FIXME: -1 IGNORES all problems ts.run(0, -1, instCallback, p) |