}
static int Pakfire_init(PakfireObject* self, PyObject* args, PyObject* kwds) {
+ char* kwlist[] = { "path", "arch", "offline", NULL };
const char* path = NULL;
- const char* arch = NULL;
+ const char* arch = NULL;
+ int offline = 0;
- if (!PyArg_ParseTuple(args, "s|z", &path, &arch))
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|zp", kwlist, &path, &arch, &offline))
return -1;
// Create a new Pakfire instance
return -1;
}
+ // Set offline mode if requested
+ if (offline)
+ pakfire_set_offline(self->pakfire, 1);
+
return 0;
}
Py_RETURN_NONE;
}
+static PyObject* Pakfire_get_offline(PakfireObject* self) {
+ int offline = pakfire_get_offline(self->pakfire);
+
+ if (offline)
+ Py_RETURN_TRUE;
+
+ Py_RETURN_FALSE;
+}
+
+static int Pakfire_set_offline(PakfireObject* self, PyObject* value) {
+ pakfire_set_offline(self->pakfire, PyObject_IsTrue(value));
+
+ return 0;
+}
+
static struct PyMethodDef Pakfire_methods[] = {
{
"dist",
NULL,
NULL
},
+ {
+ "offline",
+ (getter)Pakfire_get_offline,
+ (setter)Pakfire_set_offline,
+ NULL,
+ NULL,
+ },
{
"path",
(getter)Pakfire_get_path,
const char* pakfire_get_arch(Pakfire pakfire);
+int pakfire_get_offline(Pakfire pakfire);
+void pakfire_set_offline(Pakfire pakfire, int offline);
+
const char** pakfire_get_installonly(Pakfire pakfire);
void pakfire_set_installonly(Pakfire pakfire, const char** installonly);
pakfire_get_arch;
pakfire_get_installed_repo;
pakfire_get_installonly;
+ pakfire_get_offline;
pakfire_get_path;
pakfire_get_pool;
pakfire_get_repo;
pakfire_ref;
pakfire_search;
pakfire_set_installonly;
+ pakfire_set_offline;
pakfire_unref;
pakfire_version_compare;
pakfire_whatprovides;
char cache_path[PATH_MAX];
char arch[ARCH_MAX];
+ int offline;
+
// Pool stuff
Pool* pool;
int pool_ready;
return pakfire->arch;
}
+PAKFIRE_EXPORT int pakfire_get_offline(Pakfire pakfire) {
+ return pakfire->offline;
+}
+
+PAKFIRE_EXPORT void pakfire_set_offline(Pakfire pakfire, int offline) {
+ pakfire->offline = offline;
+}
+
PAKFIRE_EXPORT int pakfire_version_compare(Pakfire pakfire, const char* evr1, const char* evr2) {
return pool_evrcmp_str(pakfire->pool, evr1, evr2, EVRCMP_COMPARE);
}
__version__ = PAKFIRE_VERSION
def __init__(self, path="/", config=None, arch=None, distro=None, offline=False):
- _pakfire.Pakfire.__init__(self, path, arch)
+ _pakfire.Pakfire.__init__(self, path, arch, offline=offline)
# Initialise logging system
self.log = self._setup_logger()
# Default to system distribution
self.distro = distro or system.distro
- # Offline
- self.offline = offline
-
# Check if we are operating as the root user
self.check_root_user()
def __exit__(self, type, value, traceback):
pass
- def get_offline(self):
- """
- A shortcut that indicates if the system is running in offline mode.
- """
- return self._offline or self.config.get("downloader", "offline", False)
-
- def set_offline(self, offline):
- self._offline = offline
-
- offline = property(get_offline, set_offline)
-
def refresh_repositories(self, force=False):
for repo in self.repos:
repo.refresh(force=force)