mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#159: do not fail if sys.stdout has no isatty() method.
This commit is contained in:
parent
ef01782f42
commit
64d2c2c795
@ -56,7 +56,7 @@ Modi:
|
||||
|
||||
|
||||
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()
|
||||
|
||||
|
@ -532,7 +532,7 @@ def inner_main(args):
|
||||
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.')
|
||||
|
@ -18,7 +18,7 @@ from StringIO import StringIO
|
||||
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):
|
||||
@ -63,7 +63,7 @@ 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:
|
||||
|
@ -10,6 +10,7 @@
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
codes = {}
|
||||
|
||||
@ -38,6 +39,10 @@ def term_width_line(text):
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user