From: Michael Tremer Date: Sat, 8 Jun 2019 09:26:13 +0000 (+0100) Subject: pakfire: Pass on offline switch to Pakfire instance X-Git-Tag: 0.9.28~1285^2~982 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9fbe7d1b1097969f0a0f4365ee144b20aed614f;p=pakfire.git pakfire: Pass on offline switch to Pakfire instance Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/base.py b/src/pakfire/base.py index 678fda14c..d89aa230b 100644 --- a/src/pakfire/base.py +++ b/src/pakfire/base.py @@ -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: diff --git a/src/pakfire/cli.py b/src/pakfire/cli.py index bb76ec032..630af9ab3 100644 --- a/src/pakfire/cli.py +++ b/src/pakfire/cli.py @@ -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: