]> git.ipfire.org Git - pakfire.git/commitdiff
pakfire: Pass on offline switch to Pakfire instance
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 8 Jun 2019 09:26:13 +0000 (10:26 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 8 Jun 2019 09:26:13 +0000 (10:26 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/base.py
src/pakfire/cli.py

index 678fda14c34a69510e1805f1f79a5305b2a621c2..d89aa230b162699d0e0ea78a0be204586c0fd626 100644 (file)
@@ -43,7 +43,7 @@ class Pakfire(_pakfire.Pakfire):
        __version__ = PAKFIRE_VERSION
        mode = None
 
-       def __init__(self, path="/", config=None, arch=None, distro=None, cache_path=None):
+       def __init__(self, path="/", config=None, arch=None, distro=None, cache_path=None, offline=False):
                _pakfire.Pakfire.__init__(self, path, "%s" % (arch or system.native_arch))
 
                # Initialise logging system
@@ -52,6 +52,9 @@ class Pakfire(_pakfire.Pakfire):
                # 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()
 
@@ -111,12 +114,16 @@ class Pakfire(_pakfire.Pakfire):
        def __exit__(self, type, value, traceback):
                pass
 
-       @property
-       def offline(self):
+       def get_offline(self):
                """
                        A shortcut that indicates if the system is running in offline mode.
                """
-               return self.config.get("downloader", "offline", False)
+               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:
index bb76ec0327a2710ab9cc4198ab100328e1e9c79b..630af9ab355619e20b8f362cbfa458eae461af6e 100644 (file)
@@ -190,7 +190,7 @@ class Cli(object):
                                help=_("Run pakfire in offline mode."))
 
        def pakfire(self, ns):
-               p = base.Pakfire()
+               p = base.Pakfire(offline=ns.offline)
 
                # Disable repositories.
                for repo_name in ns.disable_repo: