Source code for upsies.uis.tui.utils

import sys

import logging  # isort:skip
_log = logging.getLogger(__name__)










[docs] def is_tty(): """Whether we live in a terminal and can interact with the user""" # If we have input and output, we have user interaction. It's ok if we don't have sys.stdout # (e.g. because it is redirected to a file) because prompt-toolkit writes to sys.stderr in that # case. return bool( # stdin does exist and is not redirected (sys.stdin and sys.stdin.isatty()) and ( # stdout exists and is not redirected. (sys.stdout and sys.stdout.isatty()) # stderr exists and is not redirected. or (sys.stderr and sys.stderr.isatty()) ) )