mirror of https://github.com/docker/compose.git
Use python Posix support to get tty size
stty is not portable outside *nix Note: shutil.get_terminal_size require python 3.3 Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
944660048d
commit
452880af7c
|
@ -2,20 +2,25 @@ from __future__ import absolute_import
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
|
||||
import six
|
||||
import texttable
|
||||
|
||||
from compose.cli import colors
|
||||
|
||||
if hasattr(shutil, "get_terminal_size"):
|
||||
from shutil import get_terminal_size
|
||||
else:
|
||||
from backports.shutil_get_terminal_size import get_terminal_size
|
||||
|
||||
|
||||
def get_tty_width():
|
||||
tty_size = os.popen('stty size 2> /dev/null', 'r').read().split()
|
||||
if len(tty_size) != 2:
|
||||
try:
|
||||
width, _ = get_terminal_size()
|
||||
return int(width)
|
||||
except OSError:
|
||||
return 0
|
||||
_, width = tty_size
|
||||
return int(width)
|
||||
|
||||
|
||||
class Formatter:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
backports.shutil_get_terminal_size==1.0.0
|
||||
backports.ssl-match-hostname==3.5.0.1; python_version < '3'
|
||||
cached-property==1.3.0
|
||||
certifi==2017.4.17
|
||||
|
|
3
setup.py
3
setup.py
|
@ -55,7 +55,8 @@ extras_require = {
|
|||
':python_version < "3.2"': ['subprocess32 >= 3.5.4, < 4'],
|
||||
':python_version < "3.4"': ['enum34 >= 1.0.4, < 2'],
|
||||
':python_version < "3.5"': ['backports.ssl_match_hostname >= 3.5, < 4'],
|
||||
':python_version < "3.3"': ['ipaddress >= 1.0.16, < 2'],
|
||||
':python_version < "3.3"': ['backports.shutil_get_terminal_size == 1.0.0',
|
||||
'ipaddress >= 1.0.16, < 2'],
|
||||
':sys_platform == "win32"': ['colorama >= 0.4, < 1'],
|
||||
'socks': ['PySocks >= 1.5.6, != 1.5.7, < 2'],
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue