Add a AbstractEbuildProcess class for MiscFunctionsProcess to inherit the
authorZac Medico <zmedico@gentoo.org>
Sun, 6 Dec 2009 08:03:46 +0000 (08:03 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 6 Dec 2009 08:03:46 +0000 (08:03 -0000)
_pipe and _can_log methods that used to be in the EbuildProcess class.

svn path=/main/trunk/; revision=14933

pym/_emerge/AbstractEbuildProcess.py [new file with mode: 0644]
pym/_emerge/EbuildProcess.py
pym/_emerge/MiscFunctionsProcess.py

diff --git a/pym/_emerge/AbstractEbuildProcess.py b/pym/_emerge/AbstractEbuildProcess.py
new file mode 100644 (file)
index 0000000..db59901
--- /dev/null
@@ -0,0 +1,24 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+from _emerge.SpawnProcess import SpawnProcess
+import portage
+from portage import os
+
+class AbstractEbuildProcess(SpawnProcess):
+
+       __slots__ = ('phase', 'pkg', 'settings',)
+
+       def _pipe(self, fd_pipes):
+               stdout_pipe = fd_pipes.get(1)
+               got_pty, master_fd, slave_fd = \
+                       portage._create_pty_or_pipe(copy_term_size=stdout_pipe)
+               return (master_fd, slave_fd)
+
+       def _can_log(self, slave_fd):
+               # With sesandbox, logging works through a pty but not through a
+               # normal pipe. So, disable logging if ptys are broken.
+               # See Bug #162404.
+               return not ('sesandbox' in self.settings.features \
+                       and self.settings.selinux_enabled()) or os.isatty(slave_fd)
index a6a0b362ba8dc089450b86967ed3f9e92f4fe4dd..597caf4dda767da9d6683510f676a0a27ac6127a 100644 (file)
@@ -2,13 +2,13 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-from _emerge.SpawnProcess import SpawnProcess
+from _emerge.AbstractEbuildProcess import AbstractEbuildProcess
 import portage
 from portage import os
 
-class EbuildProcess(SpawnProcess):
+class EbuildProcess(AbstractEbuildProcess):
 
-       __slots__ = ("phase", "pkg", "settings", "tree")
+       __slots__ = ('tree',)
 
        def _start(self):
                # Don't open the log file during the clean phase since the
@@ -16,20 +16,7 @@ class EbuildProcess(SpawnProcess):
                # prevents the clean phase from removing $T.
                if self.phase not in ("clean", "cleanrm"):
                        self.logfile = self.settings.get("PORTAGE_LOG_FILE")
-               SpawnProcess._start(self)
-
-       def _pipe(self, fd_pipes):
-               stdout_pipe = fd_pipes.get(1)
-               got_pty, master_fd, slave_fd = \
-                       portage._create_pty_or_pipe(copy_term_size=stdout_pipe)
-               return (master_fd, slave_fd)
-
-       def _can_log(self, slave_fd):
-               # With sesandbox, logging works through a pty but not through a
-               # normal pipe. So, disable logging if ptys are broken.
-               # See Bug #162404.
-               return not ('sesandbox' in self.settings.features \
-                       and self.settings.selinux_enabled()) or os.isatty(slave_fd)
+               AbstractEbuildProcess._start(self)
 
        def _spawn(self, args, **kwargs):
 
@@ -47,7 +34,7 @@ class EbuildProcess(SpawnProcess):
                return rval
 
        def _set_returncode(self, wait_retval):
-               SpawnProcess._set_returncode(self, wait_retval)
+               AbstractEbuildProcess._set_returncode(self, wait_retval)
 
                if self.phase not in ("clean", "cleanrm"):
                        self.returncode = portage._doebuild_exit_status_check_and_log(
index 3e2fff7ccc6df81d6b532759e9d9fcfd75df79b3..63d7873ea85dfeb506e4457e3e4683c1e97d5c7e 100644 (file)
@@ -2,16 +2,16 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-from _emerge.SpawnProcess import SpawnProcess
+from _emerge.AbstractEbuildProcess import AbstractEbuildProcess
 import portage
 from portage import os
 
-class MiscFunctionsProcess(SpawnProcess):
+class MiscFunctionsProcess(AbstractEbuildProcess):
        """
        Spawns misc-functions.sh with an existing ebuild environment.
        """
 
-       __slots__ = ("commands", "phase", "pkg", "settings")
+       __slots__ = ('commands',)
 
        def _start(self):
                settings = self.settings
@@ -26,7 +26,7 @@ class MiscFunctionsProcess(SpawnProcess):
                portage._doebuild_exit_status_unlink(
                        settings.get("EBUILD_EXIT_STATUS_FILE"))
 
-               SpawnProcess._start(self)
+               AbstractEbuildProcess._start(self)
 
        def _spawn(self, args, **kwargs):
                settings = self.settings
@@ -35,7 +35,7 @@ class MiscFunctionsProcess(SpawnProcess):
                        debug=debug, **kwargs)
 
        def _set_returncode(self, wait_retval):
-               SpawnProcess._set_returncode(self, wait_retval)
+               AbstractEbuildProcess._set_returncode(self, wait_retval)
                self.returncode = portage._doebuild_exit_status_check_and_log(
                        self.settings, self.phase, self.returncode)