- integrations
- Python
- ocx_sdk
HostEnv
HostEnvclassdataclass#
ocx_sdk._typesView sourceclass HostEnv(source: Mapping[str, str])A snapshot of the environment a spawned ocx inherits.
The mapping is copied and made read-only at construction, so neither a
later mutation of the source dict nor a write through .source can
rewrite a snapshot that was already taken. (A read-only snapshot is not
picklable — an implementation detail, not a contract.)
repr lists key names only. An ambient snapshot holds OCX_AUTH_*
values, and a repr is exactly what a traceback or a pytest diff prints.
sourceattributeinstance attribute#
source: Mapping[str, str]ambientmethodclassmethod#
def ambient() -> HostEnvReturn a snapshot of the current os.environ.
cleanmethodclassmethod#
def clean() -> HostEnvReturn an empty environment.
Hermetic, and a documented footgun: spawned tools lose PATH and fail
in ways that read like anything but a missing variable. minimal() is
the recovery.
minimalmethodclassmethod#
def minimal(windows: bool | None = None) -> HostEnvReturn only the platform-essential variables from the ambient env.
PATH, HOME, and TMPDIR everywhere; SYSTEMROOT and TEMP on
Windows. Variables that are not set are simply absent.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
windows | bool | None | None | Force the platform branch. Defaults to detecting the host; tests pass it explicitly so both branches run anywhere. |
onlymethod#
def only(*keys: str) -> HostEnvReturn a snapshot narrowed to keys that are actually set.
withoutmethod#
def without(*keys: str) -> HostEnvReturn a snapshot with keys removed.