Merged from trunk -r15189:15192
authorFabian Groffen <grobian@gentoo.org>
Mon, 11 Jan 2010 19:45:03 +0000 (19:45 -0000)
committerFabian Groffen <grobian@gentoo.org>
Mon, 11 Jan 2010 19:45:03 +0000 (19:45 -0000)
   | 15190    | Tweak TERM usage in xtermTitleReset() to match that in      |
   | zmedico  | xtermTitle().                                               |

   | 15191    | Bug #300388 - Fix terminal handling code to so term codes   |
   | zmedico  | aren't sent when TERM=dumb.                                 |

   | 15192    | Avoid potential UnicodeDecodeError with Python 3. Reported  |
   | arfrever | by devurandom.                                              |

svn path=/main/branches/prefix/; revision=15193

bin/check-implicit-pointer-usage.py
bin/ebuild
bin/emaint
bin/repoman
pym/_emerge/JobStatusDisplay.py
pym/_emerge/actions.py
pym/_emerge/main.py
pym/portage/getbinpkg.py
pym/portage/output.py

index 844ea8184dcda70ee7711821dc51fe3be13fe084..302939a1f2fbcb0a3c3662e23ea0a84fabfa45ad 100755 (executable)
@@ -19,6 +19,8 @@ from __future__ import print_function
 import re
 import sys
 
+from portage import _unicode_decode
+
 implicit_pattern = re.compile("([^:]*):(\d+): warning: implicit declaration "
                               + "of function [`']([^']*)'")
 pointer_pattern = re.compile(
@@ -37,7 +39,10 @@ last_implicit_linenum = -1
 last_implicit_func = ""
 
 while True:
-    line = sys.stdin.readline()
+    if sys.hexversion >= 0x3000000:
+        line = _unicode_decode(sys.stdin.buffer.readline())
+    else:
+        line = sys.stdin.readline()
     if line == '':
         break
     # translate unicode open/close quotes to ascii ones
index dee8fe41f9d3f70b4a50857b91aac81dbab43273..9b64f42cd9ef2a95a543cfa191e910be7da9e113 100755 (executable)
@@ -90,6 +90,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 05a08b6230850e2ed9e03adbe0938cc17fcba359..73c6924bde44811ff823be82b893d780c9d3c4b4 100755 (executable)
@@ -538,7 +538,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 1eb6ea7d46ad16eb606fa81453875212353b7abd..c181bf73fcaae09aa742643d6952ec531d6b4019 100755 (executable)
@@ -94,6 +94,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 bc0dea2ff753084214fc24f97409625c050ef3b4..c72c8255b8354655f584387dd74ad6d2c6e126c2 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()
@@ -2437,7 +2439,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 bc02874f2ebd7a7d61271c2b7ca256d7334518be..af4ec2e9c6ac3f5653ad70dbba15503388c6da45 100644 (file)
@@ -1325,7 +1325,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 8fcb0228832e55bef68ab41969a10a1085a6ed9b..fd89d9b37be582f1422757b094767ff137313c75 100644 (file)
@@ -639,7 +639,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()
index 0d5437f8daac052e49f934a819c6b37e6d7cdc9d..6caf47c19fd8caa0b9bd5824f7566c0dd32c5a1f 100644 (file)
@@ -270,7 +270,10 @@ def xtermTitleReset():
                if prompt_command == "":
                        default_xterm_title = ""
                elif prompt_command is not None:
-                       if dotitles and "TERM" in os.environ and sys.stderr.isatty():
+                       if dotitles and \
+                               'TERM' in os.environ and \
+                               _legal_terms_re.match(os.environ['TERM']) is not None and \
+                               sys.stderr.isatty():
                                from portage.process import find_binary, spawn
                                shell = os.environ.get("SHELL")
                                if not shell or not os.access(shell, os.EX_OK):