Gentoo Logo
Gentoo Spaceship

Installation:
Gentoo Handbook
Installation Docs

Documentation:
Home
Listing
About Gentoo
Philosophy
Social Contract

Resources:
Bug Tracker
Developer List
Discussion Forums
Gentoo BitTorrents
Gentoo Linux Enhancement Proposals
IRC Channels
Mailing Lists
Mirrors
Name and Logo Guidelines
Online Package Database
Security Announcements
Staffing Needs
Supporting Vendors
View our CVS

Graphics:
Logos and themes
Icons
ScreenShots

Miscellaneous Resources:
Gentoo Linux Store
Gentoo-hosted projects
IBM dW/Intel article archive




List Archive: gentoo-commits
Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-commits@g.o
From: "Zac Medico (zmedico)" <zmedico@g.o>
Subject: portage r10950 - main/trunk/pym/_emerge
Date: Sun, 06 Jul 2008 01:24:30 +0000

 1.1

Author: zmedico
Date: 2008-07-06 01:24:29 +0000 (Sun, 06 Jul 2008)
New Revision: 10950

Modified:
   main/trunk/pym/_emerge/__init__.py
Log:
Split out a reusable CompositeTask._default_exit() method that subclasses
can use as a generic task exit callback.


Modified: main/trunk/pym/_emerge/__init__.py
===================================================================
--- main/trunk/pym/_emerge/__init__.py	2008-07-06 00:44:00 UTC (rev 10949)
+++ main/trunk/pym/_emerge/__init__.py	2008-07-06 01:24:29 UTC (rev 10950)
@@ -1536,6 +1536,22 @@
 		if task is not self._current_task:
 			raise AssertionError("Unrecognized task: %s" % (task,))
 
+	def _default_exit(self, task):
+		"""
+		Calls _assert_current() on the given task and then sets the
+		composite returncode attribute if task.returncode != os.EX_OK.
+		If the task failed then self._current_task will be set to None.
+		Subclasses can use this as a generic task exit callback.
+
+		@rtype: int
+		@returns: The task.returncode attribute.
+		"""
+		self._assert_current(task)
+		if task.returncode != os.EX_OK:
+			self.returncode = task.returncode
+			self._current_task = None
+		return task.returncode
+
 class TaskSequence(CompositeTask):
 	"""
 	A collection of tasks that executes sequentially. Each task
@@ -1566,16 +1582,10 @@
 		task.start()
 
 	def _task_exit_handler(self, task):
-
-		self._assert_current(task)
-		if self._task_queue and \
-			task.returncode == os.EX_OK:
+		if self._default_exit(task) == os.EX_OK and \
+			self._task_queue:
 			self._start_next_task()
-			return
 
-		self._current_task = None
-		self.returncode = task.returncode
-
 class SubProcess(AsynchronousTask):
 	__slots__ = ("pid",)
 
@@ -1987,10 +1997,7 @@
 
 	def _clean_phase_exit(self, clean_phase):
 
-		self._assert_current(clean_phase)
-		if clean_phase.returncode != os.EX_OK:
-			self.returncode = clean_phase.returncode
-			self._current_task = None
+		if self._default_exit(clean_phase) != os.EX_OK:
 			return
 
 		pkg = self.pkg
@@ -2015,16 +2022,10 @@
 				pkg=pkg, phase=phase, scheduler=scheduler,
 				settings=settings, tree=tree))
 
-		ebuild_phases.addExitListener(self._ebuild_phases_exit)
+		ebuild_phases.addExitListener(self._default_exit)
 		self._current_task = ebuild_phases
 		ebuild_phases.start()
 
-	def _ebuild_phases_exit(self, ebuild_phases):
-
-		self._assert_current(ebuild_phases)
-		self.returncode = ebuild_phases.returncode
-		self._current_task = None
-
 class EbuildPhase(SubProcess):
 
 	__slots__ = ("fd_pipes", "phase", "pkg",

-- 
gentoo-commits@g.o mailing list


Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
gentoo-x86 commit in sys-kernel/vanilla-sources: ChangeLog vanilla-sources-2.6.26_rc9.ebuild
Next by thread:
gentoo-x86 commit in dev-haskell/hmake: hmake-3.11.ebuild hmake-3.13.ebuild
Previous by date:
gentoo-x86 commit in sys-kernel/vanilla-sources: ChangeLog vanilla-sources-2.6.26_rc9.ebuild
Next by date:
gentoo-x86 commit in dev-haskell/hmake: hmake-3.11.ebuild hmake-3.13.ebuild


Oct 06, 2008

Donate to support our development efforts.

Gentoo Centric Hosting: vr.org

VR Hosted

Tek Alchemy

Tek Alchemy

SevenL.net

SevenL.net

php|architect

php|architect

Copyright 2001-2007 Gentoo Foundation, Inc. Questions, Comments? Email www@gentoo.org.