src/_pakfire/capabilities.c \
src/_pakfire/capabilities.h \
src/_pakfire/constants.h \
+ src/_pakfire/errors.h \
src/_pakfire/package.c \
src/_pakfire/package.h \
src/_pakfire/pool.c \
#include "archive.h"
#include "capabilities.h"
#include "constants.h"
+#include "errors.h"
#include "package.h"
#include "pool.h"
#include "problem.h"
if (!module)
return NULL;
+ PyExc_DependencyError = PyErr_NewException("_pakfire.DependencyError", NULL, NULL);
+ Py_INCREF(PyExc_DependencyError);
+ PyModule_AddObject(module, "DependencyError", PyExc_DependencyError);
+
// Archive
if (PyType_Ready(&ArchiveType) < 0)
return NULL;
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2017 Pakfire development team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#ifndef PYTHON_PAKFIRE_ERRORS_H
+#define PYTHON_PAKFIRE_ERRORS_H
+
+#include <Python.h>
+
+// Exceptions
+PyObject* PyExc_DependencyError;
+
+#endif /* PYTHON_PAKFIRE_ERRORS_H */
#include <pakfire/errno.h>
#include <pakfire/request.h>
+#include "errors.h"
#include "package.h"
#include "problem.h"
#include "relation.h"
return Request_operation_return(ret);
}
+static PyObject* Request_get_problems(RequestObject* self) {
+ PyObject* list = PyList_New(0);
+
+ PakfireProblem problem = pakfire_request_get_problems(self->request);
+ while (problem) {
+ PyObject* p = new_problem(problem);
+ PyList_Append(list, p);
+
+ Py_DECREF(p);
+
+ // Move on to next problem
+ problem = pakfire_problem_next(problem);
+ }
+
+ return list;
+}
+
static PyObject* Request_solve(RequestObject* self) {
int ret = pakfire_request_solve(self->request, 0);
- if (ret)
- Py_RETURN_NONE;
+ // Raise a DependencyError with all problems
+ // if the request could not be solved
+ if (ret) {
+ PyObject* problems = Request_get_problems(self);
+ PyErr_SetObject(PyExc_DependencyError, problems);
+
+ Py_DECREF(problems);
+ return NULL;
+ }
// Allocate the transaction and return it
PakfireTransaction transaction = pakfire_request_get_transaction(self->request);
return (PyObject *)pool;
}
-static PyObject* Request_get_problems(RequestObject* self) {
- PyObject* list = PyList_New(0);
-
- PakfireProblem problem = pakfire_request_get_problems(self->request);
- while (problem) {
- PyObject* p = new_problem(problem);
- PyList_Append(list, p);
-
- Py_DECREF(p);
-
- // Move on to next problem
- problem = pakfire_problem_next(problem);
- }
-
- return list;
-}
-
static struct PyMethodDef Request_methods[] = {
{
"install",