os.isatty is now forbidden (as stream.fileno() is not implemented by StringIO)
Use stream.isatty() instead.
This commit is contained in:
parent
8508f951f5
commit
5bd70c564f
5 changed files with 9 additions and 8 deletions
|
|
@ -8,9 +8,10 @@ grep -Fn '.setlocale' ${PYFILES} && echo 'Error: do not use setlocale' && exit 5
|
|||
grep -Fn '__future__ import with_statement' ${PYFILES} && echo 'Error: with_statement useless as we do not support Python 2.5' && exit 6
|
||||
grep -nE '^[[:space:]]+except [[:alnum:] ]+,[[:alnum:] ]+' ${PYFILES} && echo 'Error: use new "as" way of naming exceptions' && exit 7
|
||||
grep -nE "^ *print " ${PYFILES} && echo 'Error: Use the print function' && exit 8
|
||||
grep -Fn ".has_key" ${PYFILES} && echo 'Error: Deprecated, use in' && exit 9
|
||||
grep -Fn ".has_key" ${PYFILES} && echo 'Error: Deprecated, use operator "in"' && exit 9
|
||||
grep -Fn "os.isatty" ${PYFILES} && echo 'Error: Use stream.isatty() instead of os.isatty(stream.fileno())' && exit 10
|
||||
MODULE_FILES=$(git ls-files|grep '^modules/.*\.py$'|tr '\n' ' ')
|
||||
grep -nE "^ *print(\(| )" ${MODULE_FILES} && echo 'Error: Use of print in modules is forbidden, use logger instead' && exit 10
|
||||
grep -nE "^ *print(\(| )" ${MODULE_FILES} && echo 'Error: Use of print in modules is forbidden, use logger instead' && exit 20
|
||||
|
||||
FLAKE8=""
|
||||
if which flake8 >/dev/null 2>&1; then
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class Pastoob(ReplApplication):
|
|||
output.write(paste.contents)
|
||||
# add a newline unless we are writing
|
||||
# in a file or in a pipe
|
||||
if os.isatty(output.fileno()):
|
||||
if output.isatty():
|
||||
output.write('\n')
|
||||
|
||||
def do_post(self, line):
|
||||
|
|
|
|||
|
|
@ -197,5 +197,5 @@ class WebContentEdit(ReplApplication):
|
|||
|
||||
# add a newline unless we are writing
|
||||
# in a file or in a pipe
|
||||
if os.isatty(output.fileno()):
|
||||
if output.isatty():
|
||||
output.write('\n')
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue