action_uninstall: use PollScheduler not Scheduler
authorZac Medico <zmedico@gentoo.org>
Sun, 7 Oct 2012 16:59:41 +0000 (09:59 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 7 Oct 2012 16:59:41 +0000 (09:59 -0700)
The PollScheduler class suffices here, if we just add a small amount of
logic to calculate the _background attribute from the emerge opts.

pym/_emerge/Scheduler.py
pym/_emerge/actions.py

index 1814344de984da141b99231c1b9ddfb2e32256fc..c5779cb9a0a4a216caa2af87d86cc8553a06c348 100644 (file)
@@ -135,8 +135,7 @@ class Scheduler(PollScheduler):
                        portage.exception.PortageException.__init__(self, value)
 
        def __init__(self, settings, trees, mtimedb, myopts,
-               spinner, mergelist=None, favorites=None, graph_config=None,
-               uninstall_only=False):
+               spinner, mergelist=None, favorites=None, graph_config=None):
                PollScheduler.__init__(self, main=True)
 
                if mergelist is not None:
@@ -152,7 +151,6 @@ class Scheduler(PollScheduler):
                self._spinner = spinner
                self._mtimedb = mtimedb
                self._favorites = favorites
-               self._uninstall_only = uninstall_only
                self._args_set = InternalPackageSet(favorites, allow_repo=True)
                self._build_opts = self._build_opts_class()
 
@@ -327,8 +325,6 @@ class Scheduler(PollScheduler):
                ignore_built_slot_operator_deps = self.myopts.get(
                        "--ignore-built-slot-operator-deps", "n") == "y"
                for root in self.trees:
-                       if self._uninstall_only:
-                               continue
                        if graph_config is None:
                                fake_vartree = FakeVartree(self.trees[root]["root_config"],
                                        pkg_cache=self._pkg_cache, dynamic_deps=dynamic_deps,
index c384dd47986748f1a4140c53b2b1b47f39408608..2707d22c1054aa10128340e2b64762787eec93d8 100644 (file)
@@ -61,6 +61,7 @@ from _emerge.emergelog import emergelog
 from _emerge.is_valid_package_atom import is_valid_package_atom
 from _emerge.MetadataRegen import MetadataRegen
 from _emerge.Package import Package
+from _emerge.PollScheduler import PollScheduler
 from _emerge.ProgressHandler import ProgressHandler
 from _emerge.RootConfig import RootConfig
 from _emerge.Scheduler import Scheduler
@@ -2680,20 +2681,19 @@ def action_uninstall(settings, trees, ldpath_mtimes,
        if action == 'deselect':
                return action_deselect(settings, trees, opts, valid_atoms)
 
-       # Create a Scheduler for calls to unmerge(), in order to cause
-       # redirection of ebuild phase output to logs as required for
-       # options such as --quiet.
-       sched = Scheduler(settings, trees, None, opts,
-               spinner, uninstall_only=True)
-       sched._background = sched._background_mode()
-       sched._status_display.quiet = True
+       # Use the same logic as the Scheduler class to trigger redirection
+       # of ebuild pkg_prerm/postrm phase output to logs as appropriate
+       # for options such as --jobs, --quiet and --quiet-build.
+       sched = PollScheduler(main=True)
+       max_jobs = opts.get("--jobs", 1)
+       sched._background = (max_jobs is True or max_jobs > 1 or
+               "--quiet" in opts or opts.get("--quiet-build") == "y")
 
        if sched._background:
-               sched.settings.unlock()
-               sched.settings["PORTAGE_BACKGROUND"] = "1"
-               sched.settings.backup_changes("PORTAGE_BACKGROUND")
-               sched.settings.lock()
-               sched.pkgsettings[eroot] = portage.config(clone=sched.settings)
+               settings.unlock()
+               settings["PORTAGE_BACKGROUND"] = "1"
+               settings.backup_changes("PORTAGE_BACKGROUND")
+               settings.lock()
 
        if action in ('clean', 'unmerge') or \
                (action == 'prune' and "--nodeps" in opts):
@@ -2701,10 +2701,11 @@ def action_uninstall(settings, trees, ldpath_mtimes,
                ordered = action == 'unmerge'
                rval = unmerge(trees[settings['EROOT']]['root_config'], opts, action,
                        valid_atoms, ldpath_mtimes, ordered=ordered,
-                       scheduler=sched._sched_iface)
+                       scheduler=sched.sched_iface)
        else:
                rval = action_depclean(settings, trees, ldpath_mtimes,
-                       opts, action, valid_atoms, spinner, scheduler=sched._sched_iface)
+                       opts, action, valid_atoms, spinner,
+                       scheduler=sched.sched_iface)
 
        return rval