diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-08-13 08:29:37 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-08-13 08:29:37 -0700 |
commit | 95559f3baaf2aa821ce57d592edc806bc4f68ecb (patch) | |
tree | 802d650c486dfa8cf9526377628dd0b140b50299 | |
parent | 2b48f228db7be788ef83f88fb85296fef880bac6 (diff) | |
download | portage-95559f3baaf2aa821ce57d592edc806bc4f68ecb.tar.gz portage-95559f3baaf2aa821ce57d592edc806bc4f68ecb.tar.bz2 portage-95559f3baaf2aa821ce57d592edc806bc4f68ecb.zip |
Write eerror messages to the log file, and only to stdout when
appropriate.
-rw-r--r-- | pym/_emerge/AbstractEbuildProcess.py | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/pym/_emerge/AbstractEbuildProcess.py b/pym/_emerge/AbstractEbuildProcess.py index c3f539dcd..991e2499d 100644 --- a/pym/_emerge/AbstractEbuildProcess.py +++ b/pym/_emerge/AbstractEbuildProcess.py @@ -1,6 +1,7 @@ -# Copyright 1999-2009 Gentoo Foundation +# Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +import codecs import textwrap from _emerge.SpawnProcess import SpawnProcess from _emerge.EbuildIpcDaemon import EbuildIpcDaemon @@ -8,7 +9,12 @@ from portage.elog.messages import eerror from portage.localization import _ from portage.package.ebuild._ipc.ExitCommand import ExitCommand from portage import os +from portage import StringIO +from portage import _encodings +from portage import _unicode_decode +from portage import _unicode_encode from portage.util._pty import _create_pty_or_pipe +from portage.util import writemsg_stdout class AbstractEbuildProcess(SpawnProcess): @@ -67,8 +73,7 @@ class AbstractEbuildProcess(SpawnProcess): "to have left a zombie process with " "pid %d.") % (phase, self.pid) - for l in textwrap.wrap(msg, 72): - eerror(l, phase=phase, key=self.settings.mycpv) + self._eerror(textwrap.wrap(msg, 72)) def _pipe(self, fd_pipes): stdout_pipe = fd_pipes.get(1) @@ -107,8 +112,28 @@ class AbstractEbuildProcess(SpawnProcess): "reproducible and you are sure that your bash binary and hardware " "are functioning properly.") % phase - for l in textwrap.wrap(msg, 72): - eerror(l, phase=phase, key=self.settings.mycpv) + self._eerror(textwrap.wrap(msg, 72)) + + def _eerror(self, lines): + out = StringIO() + phase = self._get_phase() + for line in lines: + eerror(line, phase=phase, key=self.settings.mycpv, out=out) + logfile = self.logfile + if logfile is None: + logfile = self.settings.get("PORTAGE_LOG_FILE") + msg = _unicode_decode(out.getvalue(), + encoding=_encodings['content'], errors='replace') + if msg: + if not self.background: + writemsg_stdout(msg, noiselevel=-1) + if logfile is not None: + log_file = codecs.open(_unicode_encode(logfile, + encoding=_encodings['fs'], errors='strict'), + mode='a', encoding=_encodings['content'], + errors='backslashreplace') + log_file.write(msg) + log_file.close() def _set_returncode(self, wait_retval): SpawnProcess._set_returncode(self, wait_retval) |