Bug #300388 - Fix terminal handling code to so term codes aren't sent when
authorZac Medico <zmedico@gentoo.org>
Mon, 11 Jan 2010 05:22:43 +0000 (05:22 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 11 Jan 2010 05:22:43 +0000 (05:22 -0000)
TERM=dumb.

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

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 594ac87cd25e7aa1d4f3b4ebc4cbee834c0e2207..46129437779ae1569802c46bc357897c334ef189 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 679dcae61bc73c77c4100c827dd76a8f3c5f0ee5..2a1ef0556d8294f487c6ae642128d66ecaecc26c 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 1d7fdc6863789cb6dfafa4ead2ae2dd9199502dd..2def0e89e0c2eea44bf7a2d03ec2baacb3c35f48 100644 (file)
@@ -1467,8 +1467,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()
@@ -2389,7 +2391,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 a2245892ab1d7a83cc7b0f2459dabed5328fdd06..d9916c9ddb4148990f04feaca5dd8bee8f337a4b 100644 (file)
@@ -1324,7 +1324,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()