diff options
author | Dagobert Michelsen <dam@opencsw.org> | 2015-02-06 13:43:47 +0100 |
---|---|---|
committer | Dagobert Michelsen <dam@opencsw.org> | 2015-02-06 13:43:47 +0100 |
commit | 84718156e3fe9cd76acb8578a2ce3f4ce42f50e0 (patch) | |
tree | 491336e4e44c3859a3b8e7104197b29824bcb4b6 /bin/ansible-doc | |
parent | 23a2e52cb7094937ab06d00796b37fdaf5550104 (diff) | |
download | ansible-84718156e3fe9cd76acb8578a2ce3f4ce42f50e0.tar.gz |
Use termios instead of stty for compatibility
Diffstat (limited to 'bin/ansible-doc')
-rwxr-xr-x | bin/ansible-doc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/bin/ansible-doc b/bin/ansible-doc index 4420036677..8bab0e76cd 100755 --- a/bin/ansible-doc +++ b/bin/ansible-doc @@ -25,6 +25,10 @@ import re import optparse import datetime import subprocess +import fcntl +import termios +import struct + from ansible import utils from ansible.utils import module_docs import ansible.constants as C @@ -167,7 +171,8 @@ def get_snippet_text(doc): def get_module_list_text(module_list): tty_size = 0 if os.isatty(0): - tty_size = int(os.popen('stty size', 'r').read().split()[1]) + tty_size = struct.unpack('HHHH', + fcntl.ioctl(0, termios.TIOCGWINSZ, struct.pack('HHHH', 0, 0, 0, 0)))[1] columns = max(60, tty_size) displace = max(len(x) for x in module_list) linelimit = columns - displace - 5 |