interaction module

Classes for basic interaction with the user.

Classes

class ctlbase.interaction.InteractionManager(isColoringDefault=None)

A manager for user interactions.

__init__(isColoringDefault=None)

Creates an interaction manager with a specific configuration.

Parameters:

isColoringDefault (bool | None) – If True, prompts are colored by default when printed to stdout. If None, a possibly existing COLOR_PRINT_ENVKEY environment value is used. If the latter does not exist, a default value of True is assumed.

promptForCredential(purpose=None, isColoring=None)

Prompts the user for a credential. The characters entered are not shown.

The prompt can be translated via the message key INTERACTION_CREDENTIAL_PROMPT, including a variable named purpose.

Parameters:
  • purpose (str) – A language-agnostic str to present to the user as the purpose of the requested credentials. Example: HomeServer via SMB

  • isColoring (bool | None) – If True, the prompt is colored when printed to stdout. If None, the value of isColoringDefault is used.

Raises:

ErrorMessageINTERACTION_PROMPT_ABORTED – If entering the credential was aborted by the user.

Returns:

The entered credential.

Return type:

str

isColoringDefault

If True, prompts are colored by default when printed to stdout.

Constants and defaults

ctlbase.interaction.COLOR_PRINT_ENVKEY = 'COLOR_PRINT'

Environment configuration key for the coloring of interactive prompts printed to stdout.

ctlbase.interaction.Interaction = <ctlbase.interaction.InteractionManager object>

Singleton for interacting with the user.