summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-09-28 16:37:14 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-09-28 16:37:14 +0300
commitf74def684253964fa03edb55f155dfbb5122b1bf (patch)
tree6dd5051911852612203dd1859172d1ebe1f11307 /python
parentdca55d3781401eb0ddce2759770054db7629083a (diff)
downloadlibrpm-tizen-f74def684253964fa03edb55f155dfbb5122b1bf.tar.gz
librpm-tizen-f74def684253964fa03edb55f155dfbb5122b1bf.tar.bz2
librpm-tizen-f74def684253964fa03edb55f155dfbb5122b1bf.zip
Push rpm.signalsCaught() to python level
- only implement the bare minimum in C by adding a thin wrapper for rpmsqIsCaught(), the rest can easily be done in python
Diffstat (limited to 'python')
-rw-r--r--python/rpm/__init__.py8
-rw-r--r--python/rpmmodule.c33
2 files changed, 13 insertions, 28 deletions
diff --git a/python/rpm/__init__.py b/python/rpm/__init__.py
index ca501c6bd..de0f6838c 100644
--- a/python/rpm/__init__.py
+++ b/python/rpm/__init__.py
@@ -54,3 +54,11 @@ def readHeaderFromFD(fd):
offset = None
return (h, offset)
+
+def signalsCaught(siglist):
+ caught = []
+ for sig in siglist:
+ if signalCaught(sig):
+ caught.append(sig)
+
+ return caught
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index ce3d84843..3748e8751 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -38,35 +38,12 @@ static PyObject * archScore(PyObject * self, PyObject * args, PyObject * kwds)
return Py_BuildValue("i", score);
}
-static PyObject * signalsCaught(PyObject * self, PyObject * check)
+static PyObject * signalCaught(PyObject *self, PyObject *o)
{
- PyObject *caught, *o;
- int llen;
- int signum, i;
- sigset_t newMask, oldMask;
+ int signo;
+ if (!PyArg_Parse(o, "i", &signo)) return NULL;
- if (!PyList_Check(check)) {
- PyErr_SetString(PyExc_TypeError, "list expected");
- return NULL;
- }
-
- llen = PyList_Size(check);
- caught = PyList_New(0);
-
- /* block signals while checking for them */
- (void) sigfillset(&newMask);
- (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
-
- for (i = 0; i < llen; i++) {
- o = PyList_GetItem(check, i);
- signum = PyInt_AsLong(o);
- if (rpmsqIsCaught(signum) > 0) {
- PyList_Append(caught, o);
- }
- }
- (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
-
- return caught;
+ return PyBool_FromLong(rpmsqIsCaught(signo));
}
static PyObject * checkSignals(PyObject * self, PyObject * args)
@@ -149,7 +126,7 @@ static PyMethodDef rpmModuleMethods[] = {
{ "archscore", (PyCFunction) archScore, METH_VARARGS|METH_KEYWORDS,
NULL },
- { "signalsCaught", (PyCFunction) signalsCaught, METH_O,
+ { "signalCaught", (PyCFunction) signalCaught, METH_O,
NULL },
{ "checkSignals", (PyCFunction) checkSignals, METH_VARARGS,
NULL },