os.isatty is now forbidden (as stream.fileno() is not implemented by StringIO)

Use stream.isatty() instead.
This commit is contained in:
Romain Bignon 2014-10-07 09:37:41 +02:00
commit 5bd70c564f
5 changed files with 9 additions and 8 deletions

View file

@ -64,7 +64,7 @@ class ConsoleApplication(Application):
# shell escape strings
if sys.platform == 'win32' \
or not os.isatty(sys.stdout.fileno()) \
or not sys.stdout.isatty() \
or os.getenv('ANSI_COLORS_DISABLED') is not None:
#workaround to disable bold
BOLD = ''
@ -120,7 +120,7 @@ class ConsoleApplication(Application):
def check_loaded_backends(self, default_config=None):
while len(self.enabled_backends) == 0:
print('Warning: there is currently no configured backend for %s' % self.APPNAME)
if not os.isatty(self.stdout.fileno()) or not self.ask('Do you want to configure backends?', default=True):
if not self.stdout.isatty() or not self.ask('Do you want to configure backends?', default=True):
return False
self.prompt_create_backends(default_config)

View file

@ -84,7 +84,7 @@ class IFormatter(object):
NC = ConsoleApplication.NC
def colored(self, string, color, attrs=None, on_color=None):
if self.outfile != sys.stdout or not (os.isatty(self.outfile.fileno())):
if self.outfile != sys.stdout or not self.outfile.isatty():
return string
if isinstance(attrs, basestring):
@ -100,7 +100,7 @@ class IFormatter(object):
self.outfile = outfile
# XXX if stdin is not a tty, it seems that the command fails.
if os.isatty(sys.stdout.fileno()) and os.isatty(sys.stdin.fileno()):
if sys.stdout.isatty() and sys.stdin.isatty():
if sys.platform == 'win32':
self.termrows = WConio.gettextinfo()[8]
else: