- integrations
- Python
- ocx_sdk
Ocx (3 of 4)
Ocxclass#
ocx_sdk._clientView sourcecleanmethod#
def clean(dry_run: bool = False, force: bool = False, timeout: MaybeTimeout = UNSET, retry: MaybeRetry = UNSET) -> tuple[CleanEntry, ...]Remove unreferenced objects from the local object store.
mutating=not dry_run (D5), as copy: the preview writes nothing.
The rows are the read-only view of what the store holds loose — the
kind: "consent" entries among them are the stamps OcxConfig.consent
governs, so a preview says which projects a real run would deactivate.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
dry_run | bool | False | Report what would be removed and remove nothing. |
force | bool | False | Ignore the per-user project registry and collect every
unreferenced package, including ones a registered
ocx.lock still pins. Live install symlinks are always
honoured regardless. |
timeout | MaybeTimeout | UNSET | Seconds per attempt. Omitted takes the config’s. |
retry | MaybeRetry | UNSET | Retry policy. None opts out; omitted takes the config’s,
which D5 resolves to no retries unless dry_run. |
Returns
tuple[CleanEntry, ...]- One row per removal, or intended removal.
invokemethod#
def invoke(argv: Sequence[str], *, check: bool = True, capture: bool = True, timeout: MaybeTimeout = UNSET, retry: MaybeRetry = UNSET) -> CommandResultRun an arbitrary ocx command line — the raw escape hatch.
The configured globals and the composed child environment still
apply; presentation does not, so ask for --format json yourself if
you intend to parse the output. Commands reached this way are
possible but unsupported: nothing pins their shape, and the
compatibility gate does not run.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
argv | Sequence[str] | required | The command and its arguments, without the binary. |
check | bool | True | Raise on a non-zero exit instead of returning it. |
capture | bool | True | Pipe and capture both streams. |
timeout | MaybeTimeout | UNSET | Seconds per attempt. Omitted takes the config’s. |
retry | MaybeRetry | UNSET | Retry policy. None opts out; omitted takes the config’s. |
Returns
CommandResult- The exit code and captured output.
Raises
OcxProcessError- A non-zero exit under
check. OcxTimeoutError- The timeout expired.
invoke_asyncmethodasync#
async def invoke_async(argv: Sequence[str], *, check: bool = True, capture: bool = True, timeout: MaybeTimeout = UNSET, retry: MaybeRetry = UNSET) -> CommandResultRun an arbitrary ocx command line on the event loop.
The async twin of invoke. Cancelling the awaiting task terminates
the child before the CancelledError propagates.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
argv | Sequence[str] | required | The command and its arguments, without the binary. |
check | bool | True | Raise on a non-zero exit instead of returning it. |
capture | bool | True | Pipe and capture both streams. |
timeout | MaybeTimeout | UNSET | Seconds per attempt. Omitted takes the config’s. |
retry | MaybeRetry | UNSET | Retry policy. None opts out; omitted takes the config’s. |
Returns
CommandResult- The exit code and captured output.
Raises
ValueError- The handle carries an
on_logcallback, which v0.1 refuses on async paths. OcxProcessError- A non-zero exit under
check. OcxTimeoutError- The timeout expired.
logoutmethod#
def logout(registry: str | None = None, *, timeout: MaybeTimeout = UNSET, retry: MaybeRetry = UNSET) -> LogoutResultDrop the stored credentials for a registry.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
registry | str | None | None | The registry hostname. None falls back to ocx’s
OCX_DEFAULT_REGISTRY. |
timeout | MaybeTimeout | UNSET | Seconds per attempt. Omitted takes the config’s. |
retry | MaybeRetry | UNSET | Retry policy. None opts out; omitted takes the config’s. |
Returns
LogoutResult- The registry ocx cleared. Clearing an absent entry is not an
LogoutResult- error.