def TerminalSize():
  """Returns terminal length and width as a tuple."""
  try:
    with open(os.ctermid(), 'r') as tty:
      length_width = struct.unpack(
          'hh', fcntl.ioctl(tty.fileno(), termios.TIOCGWINSZ, '1234'))
  except (IOError, OSError):
    try:
      length_width = (int(os.environ['LINES']),
                      int(os.environ['COLUMNS']))
    except (__HOLE__, KeyError):
      length_width = (24, 80)
  return length_width
dataset/ETHPy150Open google/textfsm/terminal.py/TerminalSize