class ContreeSession
Attributes
Time elapsed during execution.
Exit code of the executed command.
Execution result. Only available after successful execution.
- Raises — RuntimeError – If the result hasn’t been set.
Current state of the image in the execution lifecycle.
Stderr output from the execution.
Configured stdin source.
Stdout output from the execution.
Unique identifier of the image.
Optional tag associated with the image.
Methods
apply_files()
*args
str | Path | UploadFileSpec | list[str | Path | UploadFileSpec] | dict[str, str | Path | UploadFileSpec]
Files to upload.
files
list[str | Path | UploadFileSpec] | dict[str, str | Path | UploadFileSpec] | None
default:"None"
Files as a list or a dict mapping destination paths to sources.
When both args and files are provided, they are merged.
New image with the uploaded files baked in.
download()
Path to the file inside the image.
Local destination path. Defaults to filename from image_path.
Path to the downloaded file.
ls()
Path inside the image to list.
list[
ImageFile | ImageDirectory]List of ImageFile and ImageDirectory objects.read()
Path to the file inside the image.
File contents as bytes.
run()
Command to execute (mutually exclusive with shell).
Shell command string (mutually exclusive with command).
Command arguments.
Environment variables.
Working directory inside the image.
Hostname for the container.
Input source.
stdout
str | bytes | Path | IO[str] | IO[bytes] | Literal[-1] | type[str | bytes] | None
default:"None"
Output destination for stdout.
stderr
str | bytes | Path | IO[str] | IO[bytes] | Literal[-1] | type[str | bytes] | None
default:"None"
Output destination for stderr.
Tag for the resulting image.
files
list[str | Path | UploadFileSpec] | dict[str, str | Path | UploadFileSpec] | None
default:"None"
Files to upload into the image.
Execution timeout in seconds or as timedelta.
If True, image is discarded after execution.
number of bytes to truncate stdout and stderr. Defaults to default_truncate_output_at
New image instance configured for execution.
raises
DisposableImageRunError – If attempting to run on a disposed image.
raises
ValueError – If neither command nor shell is provided.
tag_as()
Tag name to apply to the image, or None to remove the tag.
New instance with updated tag.
untag()
New instance with tag set to None.
class ContreeSessionSync
Attributes
Time elapsed during execution.
Exit code of the executed command.
Execution result. Only available after successful execution.
- Raises — RuntimeError – If the result hasn’t been set.
Current state of the image in the execution lifecycle.
Stderr output from the execution.
Configured stdin source.
Stdout output from the execution.
Unique identifier of the image.
Optional tag associated with the image.
Methods
apply_files()
*args
str | Path | UploadFileSpec | list[str | Path | UploadFileSpec] | dict[str, str | Path | UploadFileSpec]
Files to upload.
files
list[str | Path | UploadFileSpec] | dict[str, str | Path | UploadFileSpec] | None
default:"None"
Files as a list or a dict mapping destination paths to sources.
When both args and files are provided, they are merged.
New image with the uploaded files baked in.
download()
Path to the file inside the image.
Local destination path. Defaults to filename from image_path.
Path to the downloaded file.
ls()
Path inside the image to list.
list[
ImageFileSync | ImageDirectorySync]List of ImageFileSync and ImageDirectorySync objects.popen()
Command and arguments list.
Input source.
Alternative input source (alias for stdin).
Output destination for stdout.
Output destination for stderr.
If True, treat args as shell command.
Working directory inside the image.
Execution timeout in seconds.
If True, raise on non-zero exit code.
If True, decode output as text.
Environment variables.
ContreeProcessSyncContreeProcessSync object with execution results.read()
Path to the file inside the image.
File contents as bytes.
run()
Command to execute (mutually exclusive with shell).
Shell command string (mutually exclusive with command).
Command arguments.
Environment variables.
Working directory inside the image.
Hostname for the container.
Input source.
stdout
str | bytes | Path | IO[str] | IO[bytes] | Literal[-1] | type[str | bytes] | None
default:"None"
Output destination for stdout.
stderr
str | bytes | Path | IO[str] | IO[bytes] | Literal[-1] | type[str | bytes] | None
default:"None"
Output destination for stderr.
Tag for the resulting image.
files
list[str | Path | UploadFileSpec] | dict[str, str | Path | UploadFileSpec] | None
default:"None"
Files to upload into the image.
Execution timeout in seconds or as timedelta.
If True, image is discarded after execution.
number of bytes to truncate stdout and stderr. Defaults to default_truncate_output_at
New image instance configured for execution.
raises
DisposableImageRunError – If attempting to run on a disposed image.
raises
ValueError – If neither command nor shell is provided.
tag_as()
Tag name to apply to the image, or None to remove the tag.
New instance with updated tag.
untag()
New instance with tag set to None.
wait()
New image instance with execution results.