diff --git a/sphinx/cmdline.py b/sphinx/cmdline.py index 813661bbd..3ebe6f2eb 100644 --- a/sphinx/cmdline.py +++ b/sphinx/cmdline.py @@ -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() diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index d2aa998ea..08ef24e79 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -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.') diff --git a/sphinx/setup_command.py b/sphinx/setup_command.py index ac395f39b..a33b4ee65 100644 --- a/sphinx/setup_command.py +++ b/sphinx/setup_command.py @@ -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: diff --git a/sphinx/util/console.py b/sphinx/util/console.py index 931f1ed04..4dcdd1c8d 100644 --- a/sphinx/util/console.py +++ b/sphinx/util/console.py @@ -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()