1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #10174 from dago/solaris

Use termios instead of stty for compatibility
This commit is contained in:
Brian Coca 2015-02-09 09:24:35 -05:00
commit f384e0d8d3

View file

@ -25,6 +25,10 @@ import re
import optparse import optparse
import datetime import datetime
import subprocess import subprocess
import fcntl
import termios
import struct
from ansible import utils from ansible import utils
from ansible.utils import module_docs from ansible.utils import module_docs
import ansible.constants as C import ansible.constants as C
@ -167,7 +171,8 @@ def get_snippet_text(doc):
def get_module_list_text(module_list): def get_module_list_text(module_list):
tty_size = 0 tty_size = 0
if os.isatty(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) columns = max(60, tty_size)
displace = max(len(x) for x in module_list) displace = max(len(x) for x in module_list)
linelimit = columns - displace - 5 linelimit = columns - displace - 5