Ejemplo n.º 1
0
static PyObject *
install(_GoalObject *self, PyObject *args, PyObject *kwds)
{
    DnfPackage *pkg = NULL;
    HySelector sltr = NULL;
    int flags = 0;
    g_autoptr(GError) error = NULL;
    if (!args_pkg_sltr_parse(args, kwds, &pkg, &sltr, &flags, HY_WEAK_SOLV))
        return NULL;

    if (flags & HY_WEAK_SOLV) {
        if (pkg) {
            hy_goal_install_optional(self->goal, pkg);
        } else {
            hy_goal_install_selector_optional(self->goal, sltr, &error);
        }
    } else {
        if (pkg) {
            hy_goal_install(self->goal, pkg);
        } else {
            hy_goal_install_selector(self->goal, sltr, &error);
        }
    }
    return op_error2exc(error);
}
Ejemplo n.º 2
0
static PyObject *
load_repo(_SackObject *self, PyObject *args, PyObject *kwds)
{
    const char *kwlist[] = {"repo", "build_cache", "load_filelists", "load_presto",
                      "load_updateinfo", NULL};

    HyRepo crepo = NULL;
    int build_cache = 0, load_filelists = 0, load_presto = 0, load_updateinfo = 0;
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&|iiii", (char**) kwlist,
                                     repo_converter, &crepo,
                                     &build_cache, &load_filelists,
                                     &load_presto, &load_updateinfo))
        return 0;

    int flags = 0;
    gboolean ret = 0;
    g_autoptr(GError) error = NULL;
    if (build_cache)
        flags |= HIF_SACK_LOAD_FLAG_BUILD_CACHE;
    if (load_filelists)
        flags |= HIF_SACK_LOAD_FLAG_USE_FILELISTS;
    if (load_presto)
        flags |= HIF_SACK_LOAD_FLAG_USE_PRESTO;
    if (load_updateinfo)
        flags |= HIF_SACK_LOAD_FLAG_USE_UPDATEINFO;
    Py_BEGIN_ALLOW_THREADS;
    ret = hif_sack_load_repo(self->sack, crepo, flags, &error);
    Py_END_ALLOW_THREADS;
    if (!ret)
        return op_error2exc(error);
    Py_RETURN_NONE;
}
Ejemplo n.º 3
0
static PyObject *
load_system_repo(_SackObject *self, PyObject *args, PyObject *kwds)
{
    g_autoptr(GError) error = NULL;
    const char *kwlist[] = {"repo", "build_cache", "load_filelists", "load_presto",
                      NULL};

    HyRepo crepo = NULL;
    int build_cache = 0, unused_1 = 0, unused_2 = 0;
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&iii", (char**) kwlist,
                                     repo_converter, &crepo,
                                     &build_cache, &unused_1, &unused_2))


        return 0;

    int flags = 0;
    if (build_cache)
        flags |= HIF_SACK_LOAD_FLAG_BUILD_CACHE;

    gboolean ret = hif_sack_load_system_repo(self->sack, crepo, flags, &error);
    if (!ret)
        return op_error2exc(error);
    Py_RETURN_NONE;
}
Ejemplo n.º 4
0
static PyObject *
load_repo(_SackObject *self, PyObject *args, PyObject *kwds)
{
    const char *kwlist[] = {"repo", "build_cache", "load_filelists", "load_presto",
                      "load_updateinfo", "load_other", NULL};

    PyObject * repoPyObj = NULL;
    int build_cache = 0, load_filelists = 0, load_presto = 0, load_updateinfo = 0, load_other = 0;
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|iiiii", (char**) kwlist,
                                     &repoPyObj,
                                     &build_cache, &load_filelists,
                                     &load_presto, &load_updateinfo, &load_other))
        return 0;

    // Is it old deprecated _hawkey.Repo object?
    libdnf::Repo * crepo = repoFromPyObject(repoPyObj);

    // Or is it swig object?
    if (!crepo) {
        auto repoSwigPyObj = reinterpret_cast<RepoSwigPyObject *>(PyObject_GetAttrString(repoPyObj, "this"));
        if (!repoSwigPyObj) {
            PyErr_SetString(PyExc_SystemError, "Unable to parse repoSwigPyObject");
            return NULL;
        }

        crepo = repoSwigPyObj->ptr;
        if (!crepo) {
            PyErr_SetString(PyExc_SystemError, "Unable to parse repo swig object");
            return NULL;
        }
    }

    int flags = 0;
    gboolean ret = 0;
    g_autoptr(GError) error = NULL;
    if (build_cache)
        flags |= DNF_SACK_LOAD_FLAG_BUILD_CACHE;
    if (load_filelists)
        flags |= DNF_SACK_LOAD_FLAG_USE_FILELISTS;
    if (load_presto)
        flags |= DNF_SACK_LOAD_FLAG_USE_PRESTO;
    if (load_updateinfo)
        flags |= DNF_SACK_LOAD_FLAG_USE_UPDATEINFO;
    if (load_other)
        flags |= DNF_SACK_LOAD_FLAG_USE_OTHER;
    Py_BEGIN_ALLOW_THREADS;
    ret = dnf_sack_load_repo(self->sack, crepo, flags, &error);
    Py_END_ALLOW_THREADS;
    if (!ret)
        return op_error2exc(error);
    Py_RETURN_NONE;
}
Ejemplo n.º 5
0
static PyObject *
load_system_repo(_SackObject *self, PyObject *args, PyObject *kwds)
{
    g_autoptr(GError) error = NULL;
    const char *kwlist[] = {"repo", "build_cache", "load_filelists", "load_presto",
                      NULL};

    PyObject * repoPyObj = NULL;
    libdnf::Repo * crepo = NULL;
    int build_cache = 0, unused_1 = 0, unused_2 = 0;
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oiii", (char**) kwlist,
                                     &repoPyObj,
                                     &build_cache, &unused_1, &unused_2))
        return 0;

    if (repoPyObj) {

        // Is it old deprecated _hawkey.Repo object?
        crepo = repoFromPyObject(repoPyObj);

        // Or is it swig object?
        if (!crepo) {
            auto repoSwigPyObj = reinterpret_cast<RepoSwigPyObject *>(PyObject_GetAttrString(repoPyObj, "this"));
            if (!repoSwigPyObj) {
                PyErr_SetString(PyExc_SystemError, "Unable to parse repoSwigPyObject");
                return NULL;
            }

            crepo = repoSwigPyObj->ptr;
            if (!crepo) {
                PyErr_SetString(PyExc_SystemError, "Unable to parse repo swig object");
                return NULL;
            }
        }
    }

    int flags = 0;
    if (build_cache)
        flags |= DNF_SACK_LOAD_FLAG_BUILD_CACHE;

    gboolean ret = dnf_sack_load_system_repo(self->sack, crepo, flags, &error);
    if (!ret)
        return op_error2exc(error);
    Py_RETURN_NONE;
}
Ejemplo n.º 6
0
static PyObject *
write_debugdata(_GoalObject *self, PyObject *dir_str)
{
    g_autoptr(GError) error = NULL;
    PyObject *tmp_py_str = NULL;
    const char *dir = pycomp_get_string(dir_str, &tmp_py_str);

    if (dir == NULL) {
        Py_XDECREF(tmp_py_str);
        return NULL;
    }

    gboolean ret = hy_goal_write_debugdata(self->goal, dir, &error);
    Py_XDECREF(tmp_py_str);
    if (!ret) {
        op_error2exc(error);
        return NULL;
    }
    Py_RETURN_NONE;
}