MCPcopy Create free account
hub / github.com/aws/aws-cli / determine_terminal_width

Function determine_terminal_width

awscli/table.py:43–57  ·  view source on GitHub ↗
(default_width=80)

Source from the content-addressed store, hash-verified

41
42
43def determine_terminal_width(default_width=80):
44 # If we can't detect the terminal width, the default_width is returned.
45 try:
46 from fcntl import ioctl
47 from termios import TIOCGWINSZ
48 except ImportError:
49 return default_width
50 try:
51 height, width = struct.unpack(
52 'hhhh', ioctl(sys.stdout, TIOCGWINSZ, '\000' * 8)
53 )[0:2]
54 except Exception:
55 return default_width
56 else:
57 return width
58
59
60def center_text(

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected