faust.utils.terminal

Terminal utilities.

class faust.utils.terminal.Spinner(file: ~typing.IO = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)[source]

Progress bar spinner.

bell = '\x08'
sprites: Sequence[str] = ['•', '◦', '●', '○', '◎', '◉', '⦿']
cursor_hide: str = '\x1b[?25l'
cursor_show: str = '\x1b[?25h'
hide_cursor: bool = True
stopped: bool = False
update() None[source]

Draw spinner, single iteration.

Return type:

None

stop() None[source]

Stop spinner from being emitted.

Return type:

None

reset() None[source]

Reset state or allow restart.

Return type:

None

write(s: str) None[source]

Write spinner character to terminal.

Return type:

None

begin() None[source]

Prepare terminal for spinner starting.

Return type:

None

finish() None[source]

Finish spinner and reset terminal.

Return type:

None

class faust.utils.terminal.SpinnerHandler(spinner: Spinner, **kwargs: Any)[source]

A logger handler that iterates our progress spinner for each log.

spinner: Spinner
emit(_record: LogRecord) None[source]

Emit the next spinner character.

Return type:

None

faust.utils.terminal.Table

alias of BaseTable

faust.utils.terminal.isatty(fh: IO) bool[source]

Return True if fh has a controlling terminal.

Notes

Use with e.g. sys.stdin.

Return type:

bool

faust.utils.terminal.logtable(data: Sequence[Sequence[str]], *, title: str, target: Optional[IO] = None, tty: Optional[bool] = None, headers: Optional[Sequence[str]] = None, **kwargs: Any) str[source]

Prepare table for logging.

Will use ANSI escape codes if the log file is a tty.

Return type:

str

faust.utils.terminal.table(data: Sequence[Sequence[str]], *, title: str, target: Optional[IO] = None, tty: Optional[bool] = None, **kwargs: Any) BaseTable[source]

Create suitable https://pypi.org/project/terminaltables/ table for target.

Parameters:
  • data (Sequence[Sequence[str]]) – Table data.

  • target (IO) – Target should be the destination output file for your table, and defaults to sys.stdout. ANSI codes will be used if the target has a controlling terminal, but not otherwise, which is why it’s important to pass the correct output file.

Return type:

BaseTable