Skip to content
ocx
install

Ocx (3 of 4)

Ocxclass#

Re-exported from ocx_sdk._clientView source

cleanmethod#

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

NameTypeDefaultDescription
dry_runboolFalseReport what would be removed and remove nothing.
forceboolFalseIgnore 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.
timeoutMaybeTimeoutUNSETSeconds per attempt. Omitted takes the config’s.
retryMaybeRetryUNSETRetry 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) -> CommandResult

Run 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

NameTypeDefaultDescription
argvSequence[str]requiredThe command and its arguments, without the binary.
checkboolTrueRaise on a non-zero exit instead of returning it.
captureboolTruePipe and capture both streams.
timeoutMaybeTimeoutUNSETSeconds per attempt. Omitted takes the config’s.
retryMaybeRetryUNSETRetry 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) -> CommandResult

Run 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

NameTypeDefaultDescription
argvSequence[str]requiredThe command and its arguments, without the binary.
checkboolTrueRaise on a non-zero exit instead of returning it.
captureboolTruePipe and capture both streams.
timeoutMaybeTimeoutUNSETSeconds per attempt. Omitted takes the config’s.
retryMaybeRetryUNSETRetry policy. None opts out; omitted takes the config’s.

Returns

CommandResult
The exit code and captured output.

Raises

ValueError
The handle carries an on_log callback, 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) -> LogoutResult

Drop the stored credentials for a registry.

Parameters

NameTypeDefaultDescription
registrystr | NoneNoneThe registry hostname. None falls back to ocx’s OCX_DEFAULT_REGISTRY.
timeoutMaybeTimeoutUNSETSeconds per attempt. Omitted takes the config’s.
retryMaybeRetryUNSETRetry policy. None opts out; omitted takes the config’s.

Returns

LogoutResult
The registry ocx cleared. Clearing an absent entry is not an
LogoutResult
error.