The 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[source]

Raised when the terminal dimensions cannot be determined.

osrf_pycommon.terminal_utils.get_terminal_dimensions()[source]

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)[source]

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