From: Michael Tremer Date: Fri, 14 Mar 2025 17:59:02 +0000 (+0000) Subject: python: transaction: Add function to run the transaction X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=68ad3b50696c27799fc33ebca4ea291d47b5f78d;p=pakfire.git python: transaction: Add function to run the transaction Signed-off-by: Michael Tremer --- diff --git a/src/python/transaction.c b/src/python/transaction.c index 8dfb7af6..a56bd04e 100644 --- a/src/python/transaction.c +++ b/src/python/transaction.c @@ -161,6 +161,36 @@ ERROR: return NULL; } +static PyObject* Transaction_run(TransactionObject* self) { + char* problems = NULL; + int r; + + // Run the transaction + r = pakfire_transaction_run(self->transaction); + if (r < 0) { + errno = -r; + PyErr_SetFromErrno(PyExc_OSError); + goto ERROR; + + // Solving failed :( + } else if (r > 0) { + PyErr_SetString(PyExc_DependencyError, problems); + goto ERROR; + } + + // Problems should never be set here + assert(problems == NULL); + + // Return None if everything was okay + Py_RETURN_NONE; + +ERROR: + if (problems) + free(problems); + + return NULL; +} + static struct PyMethodDef Transaction_methods[] = { { "install", @@ -174,6 +204,12 @@ static struct PyMethodDef Transaction_methods[] = { METH_VARARGS|METH_KEYWORDS, NULL, }, + { + "run", + (PyCFunction)Transaction_run, + METH_NOARGS, + NULL, + }, { "solve", (PyCFunction)Transaction_solve,