From: Michael Tremer Date: Sat, 27 Oct 2012 09:09:59 +0000 (+0200) Subject: Remove mode argument from Pakfire class. X-Git-Tag: 0.9.24~53 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=73776c237ad6a0d28a964ee0a2d498b1ae7b67a4;p=pakfire.git Remove mode argument from Pakfire class. --- diff --git a/python/pakfire/api.py b/python/pakfire/api.py index d044c4ba5..c44c9abec 100644 --- a/python/pakfire/api.py +++ b/python/pakfire/api.py @@ -25,6 +25,7 @@ import client from errors import * Pakfire = base.Pakfire +PakfireBuilder = base.PakfireBuilder def install(requires, ignore_recommended=False, **pakfire_args): pakfire = Pakfire(**pakfire_args) @@ -81,7 +82,7 @@ def grouplist(group, **pakfire_args): return pakfire.grouplist(group) def _build(pkg, resultdir, **kwargs): - pakfire = Pakfire(mode="builder", **kwargs) + pakfire = PakfireBuilder(**kwargs) return pakfire._build(pkg, resultdir, **kwargs) diff --git a/python/pakfire/base.py b/python/pakfire/base.py index 7b2adef31..ad663e073 100644 --- a/python/pakfire/base.py +++ b/python/pakfire/base.py @@ -43,6 +43,8 @@ from constants import * from i18n import _ class Pakfire(object): + mode = None + RELATIONS = ( (">=", satsolver.REL_GE,), ("<=", satsolver.REL_LE,), @@ -51,12 +53,8 @@ class Pakfire(object): (">" , satsolver.REL_GT,), ) - def __init__(self, mode=None, path="/", config=None, configs=None, arch=None, + def __init__(self, path="/", config=None, configs=None, arch=None, enable_repos=None, disable_repos=None, **kwargs): - # Set the mode. - assert mode in ("normal", "builder", "server",) - self.mode = mode - # Check if we are operating as the root user. self.check_root_user() @@ -64,10 +62,10 @@ class Pakfire(object): self.path = path # Configure the instance of Pakfire we just started. - if mode == "builder": + if self.mode == "builder": self.path = os.path.join(BUILD_ROOT, util.random_string()) - elif mode == "normal": + elif not mode: # check if we are actually running on an ipfire system. if self.path == "/": self.check_is_ipfire() @@ -784,3 +782,11 @@ class Pakfire(object): # Process the transaction. t.run() + + +class PakfireBuilder(Pakfire): + mode = "builder" + + +class PakfireServer(Pakfire): + mode = "server" diff --git a/python/pakfire/builder.py b/python/pakfire/builder.py index 9fb295354..c0c0d43bc 100644 --- a/python/pakfire/builder.py +++ b/python/pakfire/builder.py @@ -145,12 +145,7 @@ class BuildEnviron(object): log.error(_("Please do so in builder.conf or on the CLI.")) raise ConfigError, _("Distribution configuration is missing.") - self.pakfire = base.Pakfire( - mode="builder", - config=config, - arch=arch, - **pakfire_args - ) + self.pakfire = base.PakfireBuilder(config=config, arch=arch, **pakfire_args) self.distro = self.pakfire.distro self.path = self.pakfire.path