From 04052f030a975ee8e2a8d44fcb8402ea4f815b31 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 23 May 2011 15:12:24 -0700 Subject: [PATCH] PackageUninstall: use _unmerge_display() This is preparation for asynchronous support. --- pym/_emerge/PackageUninstall.py | 51 ++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/pym/_emerge/PackageUninstall.py b/pym/_emerge/PackageUninstall.py index 5e8850b18..0e9130713 100644 --- a/pym/_emerge/PackageUninstall.py +++ b/pym/_emerge/PackageUninstall.py @@ -1,34 +1,51 @@ -# Copyright 1999-2010 Gentoo Foundation +# Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import logging import portage from portage import os -from _emerge.AsynchronousTask import AsynchronousTask -from _emerge.unmerge import unmerge -from _emerge.UninstallFailure import UninstallFailure +from _emerge.emergelog import emergelog +from _emerge.CompositeTask import CompositeTask +from _emerge.unmerge import _unmerge_display -class PackageUninstall(AsynchronousTask): +class PackageUninstall(CompositeTask): __slots__ = ("world_atom", "ldpath_mtimes", "opts", - "pkg", "scheduler", "settings") + "pkg", "settings") def _start(self): - try: - retval = unmerge(self.pkg.root_config, self.opts, "unmerge", - [self.pkg.cpv], self.ldpath_mtimes, clean_world=0, - clean_delay=0, raise_on_error=1, scheduler=self.scheduler, - writemsg_level=self._writemsg_level) - except UninstallFailure as e: - self.returncode = e.status - else: - self.returncode = os.EX_OK - if retval == 1: - self.world_atom(self.pkg) + retval, pkgmap = _unmerge_display(self.pkg.root_config, + self.opts, "unmerge", [self.pkg.cpv], clean_delay=0, + writemsg_level=self._writemsg_level) + + if retval != os.EX_OK: + self.returncode = retval + self.wait() + return + + self._writemsg_level(">>> Unmerging %s...\n" % (self.pkg.cpv,), + noiselevel=-1) + self._emergelog("=== Unmerging... (%s)" % (self.pkg.cpv,)) + + cat, pf = portage.catsplit(self.pkg.cpv) + retval = portage.unmerge(cat, pf, settings=self.settings, + vartree=self.pkg.root_config.trees["vartree"], + ldpath_mtimes=self.ldpath_mtimes, + scheduler=self.scheduler) + if retval != os.EX_OK: + self._emergelog(" !!! unmerge FAILURE: %s" % (self.pkg.cpv,)) + else: + self._emergelog(" >>> unmerge success: %s" % (self.pkg.cpv,)) + self.world_atom(self.pkg) + + self.returncode = retval self.wait() + def _emergelog(self, msg): + emergelog("notitles" not in self.settings.features, msg) + def _writemsg_level(self, msg, level=0, noiselevel=0): log_path = self.settings.get("PORTAGE_LOG_FILE") -- 2.26.2