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):
|
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
|
# Windows' poor cmd box doesn't understand ANSI sequences
|
||||||
nocolor()
|
nocolor()
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ def inner_main(args):
|
|||||||
d = {}
|
d = {}
|
||||||
texescape.init()
|
texescape.init()
|
||||||
|
|
||||||
if not sys.stdout.isatty() or not color_terminal():
|
if not color_terminal():
|
||||||
nocolor()
|
nocolor()
|
||||||
|
|
||||||
print bold('Welcome to the Sphinx quickstart utility.')
|
print bold('Welcome to the Sphinx quickstart utility.')
|
||||||
|
@ -18,7 +18,7 @@ from StringIO import StringIO
|
|||||||
from distutils.cmd import Command
|
from distutils.cmd import Command
|
||||||
|
|
||||||
from sphinx.application import Sphinx
|
from sphinx.application import Sphinx
|
||||||
from sphinx.util.console import darkred, nocolor
|
from sphinx.util.console import darkred, nocolor, color_terminal
|
||||||
|
|
||||||
|
|
||||||
class BuildDoc(Command):
|
class BuildDoc(Command):
|
||||||
@ -63,7 +63,7 @@ class BuildDoc(Command):
|
|||||||
self.mkpath(self.builder_target_dir)
|
self.mkpath(self.builder_target_dir)
|
||||||
|
|
||||||
def run(self):
|
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
|
# Windows' poor cmd box doesn't understand ANSI sequences
|
||||||
nocolor()
|
nocolor()
|
||||||
if not self.verbose:
|
if not self.verbose:
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
codes = {}
|
codes = {}
|
||||||
|
|
||||||
@ -38,6 +39,10 @@ def term_width_line(text):
|
|||||||
return text.ljust(_tw) + '\r'
|
return text.ljust(_tw) + '\r'
|
||||||
|
|
||||||
def color_terminal():
|
def color_terminal():
|
||||||
|
if not hasattr(sys.stdout, 'isatty'):
|
||||||
|
return False
|
||||||
|
if not sys.stdout.isatty():
|
||||||
|
return False
|
||||||
if 'COLORTERM' in os.environ:
|
if 'COLORTERM' in os.environ:
|
||||||
return True
|
return True
|
||||||
term = os.environ.get('TERM', 'dumb').lower()
|
term = os.environ.get('TERM', 'dumb').lower()
|
||||||
|
Loading…
Reference in New Issue
Block a user