Bug #300388 - Fix terminal handling code to so term codes aren't sent when
authorZac Medico <zmedico@gentoo.org>
Fri, 29 Jan 2010 18:47:51 +0000 (18:47 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 29 Jan 2010 18:47:51 +0000 (18:47 -0000)
TERM=dumb. (trunk r15191)

svn path=/main/branches/2.1.7/; revision=15246

bin/ebuild
bin/emaint
bin/repoman
pym/_emerge/JobStatusDisplay.py
pym/_emerge/actions.py
pym/_emerge/main.py
pym/portage/getbinpkg.py

index dc3f448c46e903be705e2bfe6d61184274695fd5..d8eec06a76262c85cb9e0b0c2383d54368b9e500 100755 (executable)
@@ -88,6 +88,7 @@ if debug and "python-trace" in portage.features:
 if not opts.color == 'y' and \
        (opts.color == 'n' or \
        portage.settings.get('NOCOLOR') in ('yes', 'true') or \
+       portage.settings.get('TERM') == 'dumb' or \
        not sys.stdout.isatty()):
        portage.output.nocolor()
        portage.settings.unlock()
index 9da3f422013bb072d207478fa8af42614147c1f0..90301dbff778d8e41b3b746dfbff89de6b462c0e 100755 (executable)
@@ -536,7 +536,7 @@ def emaint_main(myargv):
                status = "Attempting to fix %s"
                func = "fix"
 
-       isatty = sys.stdout.isatty()
+       isatty = os.environ.get('TERM') != 'dumb' and sys.stdout.isatty()
        for task in tasks:
                print(status % task.name())
                inst = task()
index 7778447d5bbeac69b1f20b630b5f5c2c1324eab3..ec6f2d41e16881ad1d88bd959cba8807fcf09191 100755 (executable)
@@ -96,6 +96,7 @@ repoman_settings = portage.config(local_config=False,
 repoman_settings.lock()
 
 if repoman_settings.get("NOCOLOR", "").lower() in ("yes", "true") or \
+       repoman_settings.get('TERM') == 'dumb' or \
        not sys.stdout.isatty():
        nocolor()
 
index dfc766d26df32420edcc5d34da5aa5b1a3139ed7..83603ed870be6f10c9a083142f292d292f41b5fa 100644 (file)
@@ -55,7 +55,9 @@ class JobStatusDisplay(object):
                object.__setattr__(self, "_jobs_column_width", width - 32)
                self.reset()
 
-               isatty = hasattr(self.out, "isatty") and self.out.isatty()
+               isatty = os.environ.get('TERM') != 'dumb' and \
+                       hasattr(self.out, 'isatty') and \
+                       self.out.isatty()
                object.__setattr__(self, "_isatty", isatty)
                if not isatty or not self._init_term():
                        term_codes = {}
index 14854c06fa827bfc8d84710ed2c307ad61b163e0..66a47da8f69b072cbcea16bc28b00417fbd07be4 100644 (file)
@@ -1291,8 +1291,10 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
 
        porttrees = [tree_data.path for tree_data in porttrees_data]
 
-       isatty = sys.stdout.isatty()
-       quiet = not isatty or '--quiet' in myopts
+       quiet = settings.get('TERM') == 'dumb' or \
+               '--quiet' in myopts or \
+               not sys.stdout.isatty()
+
        onProgress = None
        if not quiet:
                progressBar = portage.output.TermProgressBar()
@@ -2213,7 +2215,8 @@ def adjust_config(myopts, settings):
                        portage.output.havecolor = 0
                        settings["NOCOLOR"] = "true"
                settings.backup_changes("NOCOLOR")
-       elif not sys.stdout.isatty() and settings.get("NOCOLOR") != "no":
+       elif settings.get('TERM') == 'dumb' or \
+               not sys.stdout.isatty():
                portage.output.havecolor = 0
                settings["NOCOLOR"] = "true"
                settings.backup_changes("NOCOLOR")
index d592377f90027b15bc09505c791ca9c356dd4462..7b6221107d74df45f2fda5c149d1f7313a0dca0e 100644 (file)
@@ -1179,7 +1179,9 @@ def emerge_main():
                        portage.debug.set_trace(True)
 
        if not ("--quiet" in myopts):
-               if not sys.stdout.isatty() or ("--nospinner" in myopts):
+               if '--nospinner' in myopts or \
+                       settings.get('TERM') == 'dumb' or \
+                       not sys.stdout.isatty():
                        spinner.update = spinner.update_basic
 
        if myaction == 'version':
index 42938de99b59f0d972ef96ae42782b9d044cd750..26b2bb1fc9f4f6aa1f41f23d0fc3a6e69f790ad0 100644 (file)
@@ -638,7 +638,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
                        self.out.flush()
 
        cache_stats = CacheStats(out)
-       have_tty = out.isatty()
+       have_tty = os.environ.get('TERM') != 'dumb' and out.isatty()
        if have_tty:
                cache_stats.display()
        binpkg_filenames = set()