osrf_pycommon.terminal_utils module

This module has a miscellaneous set of functions for working with terminals.

You can use the get_terminal_dimensions() to get the width and height of the terminal as a tuple.

You can also use the is_tty() function to determine if a given object is a tty.

exception osrf_pycommon.terminal_utils.GetTerminalDimensionsError

Bases: Exception

Raised when the terminal dimensions cannot be determined.

osrf_pycommon.terminal_utils.get_terminal_dimensions()

Returns the width and height of the terminal.

Returns:

width and height in that order as a tuple

Return type:

tuple

Raises:

GetTerminalDimensionsError when the terminal dimensions cannot be determined

osrf_pycommon.terminal_utils.is_tty(stream)

Returns True if the given stream is a tty, else False

Parameters:

stream – object to be checked for being a tty

Returns:

True if the given object is a tty, otherwise False

Return type:

bool