Py_RETURN_NONE;
}
+static PyObject* Pakfire_refresh(PakfireObject* self, PyObject* args) {
+ int force = 0;
+
+ if (!PyArg_ParseTuple(args, "|p", &force))
+ return NULL;
+
+ int r = pakfire_refresh(self->pakfire, force);
+ if (r) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
static struct PyMethodDef Pakfire_methods[] = {
{
"bind",
METH_VARARGS,
NULL
},
+ {
+ "refresh",
+ (PyCFunction)Pakfire_refresh,
+ METH_VARARGS,
+ NULL,
+ },
{
"search",
(PyCFunction)Pakfire_search,
const char* pakfire_get_path(Pakfire pakfire);
int pakfire_clean(Pakfire pakfire, int flags);
+int pakfire_refresh(Pakfire pakfire, int flags);
int pakfire_bind(Pakfire pakfire, const char* src, const char* dst, int flags);
return pakfire_foreach_repo(pakfire, pakfire_repo_clean, flags);
}
+PAKFIRE_EXPORT int pakfire_refresh(Pakfire pakfire, int flags) {
+ // Do nothing if running in offline mode
+ if (pakfire_has_flag(pakfire, PAKFIRE_FLAGS_OFFLINE))
+ return 0;
+
+ return pakfire_foreach_repo(pakfire, pakfire_repo_refresh, flags);
+}
+
static int pakfire_copy(Pakfire pakfire, const char* src, const char* dst) {
char buffer[512 * 1024];
struct archive* reader = NULL;
}
PAKFIRE_EXPORT PakfirePackageList pakfire_whatprovides(Pakfire pakfire, const char* what, int flags) {
+ // Refresh repositories
+ int r = pakfire_refresh(pakfire, 0);
+ if (r)
+ return NULL;
+
if (flags & PAKFIRE_NAME_ONLY) {
flags &= ~PAKFIRE_NAME_ONLY;
}
PAKFIRE_EXPORT PakfirePackageList pakfire_search(Pakfire pakfire, const char* what, int flags) {
+ // Refresh repositories
+ int r = pakfire_refresh(pakfire, 0);
+ if (r)
+ return NULL;
+
return pakfire_pool_dataiterator(pakfire, what, 0, PAKFIRE_SUBSTRING);
}
return 1;
}
+ // Refresh repositories
+ r = pakfire_refresh(pakfire, 0);
+ if (r)
+ goto ERROR;
+
// Create a new request
r = pakfire_request_create(&request, pakfire, 0);
if (r)
Called to initialize this Pakfire instance when
the context is entered.
"""
- # Refresh repositories
- self.refresh_repositories()
-
return PakfireContext(self)
def __exit__(self, type, value, traceback):
pass
- def refresh_repositories(self, force=False):
- for repo in self.repos:
- repo.refresh(force=force)
-
class PakfireContext(object):
"""