From 61262d1c27e372abb3dc9ba914b1640d2ba65a7f Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 7 Oct 2012 09:59:41 -0700 Subject: [PATCH] action_uninstall: use PollScheduler not Scheduler 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 | 6 +----- pym/_emerge/actions.py | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 1814344de..c5779cb9a 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -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, diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index c384dd479..2707d22c1 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -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 -- 2.26.2