diff options
Diffstat (limited to 'pym/_emerge/BinpkgVerifier.py')
-rw-r--r-- | pym/_emerge/BinpkgVerifier.py | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/pym/_emerge/BinpkgVerifier.py b/pym/_emerge/BinpkgVerifier.py index 83a02c76c..02a942c94 100644 --- a/pym/_emerge/BinpkgVerifier.py +++ b/pym/_emerge/BinpkgVerifier.py @@ -7,7 +7,9 @@ import sys import portage from portage import os from portage import _encodings +from portage import _unicode_decode from portage import _unicode_encode +from portage import StringIO from portage.package.ebuild.fetch import _checksum_failure_temp_file import codecs @@ -27,27 +29,10 @@ class BinpkgVerifier(AsynchronousTask): rval = os.EX_OK stdout_orig = sys.stdout stderr_orig = sys.stderr - log_file = None - if self.background and self.logfile is not None: - if sys.hexversion >= 0x3000000: - # Since we are replacing the sys.std* streams, - # we need to use the normal open() function - # so that we get the right class (otherwise our - # code that expects the 'buffer' attribute - # will break). - log_file = open(_unicode_encode(self.logfile, - encoding=_encodings['fs'], errors='strict'), - mode='a', encoding=_encodings['content'], - errors='backslashreplace') - else: - # For python2, sys.std* are expected to be binary streams. - log_file = open(_unicode_encode(self.logfile, - encoding=_encodings['fs'], errors='strict'), - mode='ab') + out = portage.StringIO() try: - if log_file is not None: - sys.stdout = log_file - sys.stderr = log_file + sys.stdout = out + sys.stderr = out try: bintree.digestCheck(pkg) except portage.exception.FileNotFound: @@ -69,7 +54,7 @@ class BinpkgVerifier(AsynchronousTask): if rval == os.EX_OK: # If this was successful, discard the log here since otherwise # we'll get multiple logs for the same package. - if log_file is not None: + if self.logfile is not None: try: os.unlink(self.logfile) except OSError: @@ -83,8 +68,11 @@ class BinpkgVerifier(AsynchronousTask): finally: sys.stdout = stdout_orig sys.stderr = stderr_orig - if log_file is not None: - log_file.close() + + msg = _unicode_decode(out.getvalue(), + encoding=_encodings['content'], errors='replace') + if msg: + self.scheduler.output(msg, log_path=self.logfile) self.returncode = rval self.wait() |