]> git.ipfire.org Git - pakfire.git/commitdiff
Remove mode argument from Pakfire class.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Oct 2012 09:09:59 +0000 (11:09 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Oct 2012 09:09:59 +0000 (11:09 +0200)
python/pakfire/api.py
python/pakfire/base.py
python/pakfire/builder.py

index d044c4ba5118047be35aaf0868eff3bf627fad33..c44c9abec2b1cd4b786770f53928b58b93a0a5ae 100644 (file)
@@ -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)
 
index 7b2adef316b4a5d2cc21664f79118ea7ca2ca5cb..ad663e073dc3c63fe08288490efe8bb5a6ac9497 100644 (file)
@@ -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"
index 9fb29535441f4c933e342ae1bada8bc24b30098d..c0c0d43bccc188526292e4631bfa6d70be6e4dd8 100644 (file)
@@ -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