- integrations
- Python
- ocx_sdk
Ocx, Project
Ocxclass#
ocx_sdk._clientView sourceprojectmethod#
def project(path: str | Path) -> ProjectReturn a project-tier handle rooted at path.
The path is made absolute immediately, so the handle keeps targeting the same project no matter what the working directory does later.
ocx’s --project names the project file, the way Cargo’s
--manifest-path does, and accepts any filename. A directory is the
obvious thing to pass and the common case, so it is resolved to the
ocx.toml inside it.
A path that does not exist yet — which is every path init() is
called on — is read by its name: a .toml suffix means the file,
anything else means the directory. Guessing “file” there would make
project('/srv/build').init() write /srv/ocx.toml, one level above
where the caller pointed.
Parameters
| Name | Type | Description |
|---|---|---|
path | str | Path | The project directory, or the project file directly. |
Returns
Project- A handle whose every call carries
--project <file>.
versionmethod#
def version(timeout: MaybeTimeout = UNSET, retry: MaybeRetry = UNSET) -> strReturn the binary’s version, as ocx version prints it.
Reads the plain output — a bare semver line — which is ocx’s
documented stable script contract and the recorded exception to the
--format json pinning rule. This call is the compatibility probe
itself, so it never triggers the gate and never raises
VersionCompatError: asking an unsupported binary what it is has to
work. The richer JSON envelope is available through
VersionInfo.from_json(ocx.invoke(["--format", "json", "version"]).stdout).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
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
str- The version string, whitespace stripped.
Projectclassdataclass#
ocx_sdk._clientView sourceclass Project(_runner: _Runner, path: Path)A project-tier handle: every call carries --project <file>.
Obtained from Ocx.project(path), never constructed directly. Because
the path travels explicitly on every call, no method depends on the
working directory, and an ambient OCX_PROJECT can never retarget one.
init is the exception, and only because ocx’s is: it takes no flags and
writes into the working directory, so the handle sets that instead.
Attributes
| Name | Type | Description |
|---|---|---|
path | Path | The absolute project file — the ocx.toml itself, which is what
ocx’s --project names. |
session_config | OcxConfig | The OcxConfig every call spawns under. |