1. Georg Brandl
  2. sphinx

Commits

Georg Brandl  committed ff55a08

#159: do not fail if sys.stdout has no isatty() method.

  • Participants
  • Parent commits 910b0b0
  • Branches default

Comments (0)

Files changed (4)

File sphinx/cmdline.py

View file
 
 
 def main(argv):
-    if not sys.stdout.isatty() or not color_terminal():
+    if not color_terminal():
         # Windows' poor cmd box doesn't understand ANSI sequences
         nocolor()
 

File sphinx/quickstart.py

View file
     d = {}
     texescape.init()
 
-    if not sys.stdout.isatty() or not color_terminal():
+    if not color_terminal():
         nocolor()
 
     print bold('Welcome to the Sphinx quickstart utility.')

File sphinx/setup_command.py

View file
 from distutils.cmd import Command
 
 from sphinx.application import Sphinx
-from sphinx.util.console import darkred, nocolor
+from sphinx.util.console import darkred, nocolor, color_terminal
 
 
 class BuildDoc(Command):
         self.mkpath(self.builder_target_dir)
 
     def run(self):
-        if not sys.stdout.isatty() or sys.platform == 'win32':
+        if not color_terminal():
             # Windows' poor cmd box doesn't understand ANSI sequences
             nocolor()
         if not self.verbose:

File sphinx/util/console.py

View file
 """
 
 import os
+import sys
 
 codes = {}
 
         return text.ljust(_tw) + '\r'
 
 def color_terminal():
+    if not hasattr(sys.stdout, 'isatty'):
+        return False
+    if not sys.stdout.isatty():
+        return False
     if 'COLORTERM' in os.environ:
         return True
     term = os.environ.get('TERM', 'dumb').lower()