BinpkgVerifier: disable color in background mode
authorZac Medico <zmedico@gentoo.org>
Fri, 18 Feb 2011 12:05:16 +0000 (04:05 -0800)
committerZac Medico <zmedico@gentoo.org>
Sun, 20 Feb 2011 00:01:55 +0000 (16:01 -0800)
pym/_emerge/BinpkgVerifier.py

index 6c71977c60486a40dbb27213edd6f8f70ed717df..379c862af3de7d7c16fb27a130d5acac962ca2ac 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from _emerge.AsynchronousTask import AsynchronousTask
@@ -26,11 +26,14 @@ class BinpkgVerifier(AsynchronousTask):
                rval = os.EX_OK
                stdout_orig = sys.stdout
                stderr_orig = sys.stderr
+               global_havecolor = portage.output.havecolor
                out = portage.StringIO()
                file_exists = True
                try:
                        sys.stdout = out
                        sys.stderr = out
+                       if portage.output.havecolor:
+                               portage.output.havecolor = not self.background
                        try:
                                bintree.digestCheck(pkg)
                        except portage.exception.FileNotFound:
@@ -61,6 +64,7 @@ class BinpkgVerifier(AsynchronousTask):
                finally:
                        sys.stdout = stdout_orig
                        sys.stderr = stderr_orig
+                       portage.output.havecolor = global_havecolor
 
                msg = _unicode_decode(out.getvalue(),
                        encoding=_encodings['content'], errors='replace')