Module zut.context

Information about the execution context: script path and name, user scopes, SID, etc.

Functions

assert_root(*[, logger])

Raise an exception if the current user is not root (Linux/macOS) or does not have admin privileges (Windows).

get_origin_gid()

get_origin_uid()

get_script_name()

get_script_path()

Return the path to the Python file that was originally executed (e.g. my_module/__main__.py or .venv/bin/my-module).

getsid()

Retrieve the current user's global SID (Security Identifier) on Windows, on on Linux if the host is part of an Active Directory domain.

in_docker_container()

Indicate whether the application is running in a Docker container.

is_root()

Indicate whether the application is running as root (Linux/macOS) or with admin privileges (Windows).

is_user_scoped()

Indicate whether the application is running in user-scoped context (typically: interactive, human user) or in system-scoped context (typically: daemon, service, non-interactive): - When in user-scoped context, the application should read and store data in user directories by default (XDG/APPDATA/home-based defaults).