Skip to main content

class ContreeImage

Attributes

timedelta
Time elapsed during execution.
int
Exit code of the executed command.
ContreeResult
Execution result. Only available after successful execution.
ImageState
Current state of the image in the execution lifecycle.
str | bytes | Path | Writable | AsyncWritable | None
Stderr output from the execution.
str | bytes | Path | Readable | AsyncReadable | None
Configured stdin source.
str | bytes | Path | Writable | AsyncWritable | None
Stdout output from the execution.
UUID | None
Unique identifier of the image.
str | None
Optional tag associated with the image.

Methods

apply_files()

Upload files into a new image derived from this one.
str | Path | UploadFileSpec | list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | UploadFileSpec]
Files to upload.
list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | 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.
TypeVar(_T, bound= _ImageLikeBase)
New image with the uploaded files baked in.

download()

Download a file from the image to local filesystem.
str | PurePosixPath
required
Path to the file inside the image.
str | Path | None
default:"None"
Local destination path. Defaults to filename from image_path.
Path | None
Path to the downloaded file.

ls()

List files and directories at the given path.
str | PurePosixPath
default:"'/'"
Path inside the image to list.
list[ImageFile | ImageDirectory]
list[ImageFile | ImageDirectory]List of ImageFile and ImageDirectory objects.

read()

Read file contents from the image.
str | PurePosixPath
required
Path to the file inside the image.
bytes
File contents as bytes.

run()

Prepare image for command execution.
str | None
default:"None"
Command to execute (mutually exclusive with shell).
str | None
default:"None"
Shell command string (mutually exclusive with command).
Iterable[str] | None
default:"None"
Command arguments.
dict[str, str] | None
default:"None"
Environment variables.
str | None
default:"None"
Working directory inside the image.
str | None
default:"None"
Hostname for the container.
str | bytes | Path | Readable | AsyncReadable | None
default:"None"
Input source.
str | Path | Writable | AsyncWritable | Literal[-1] | type[str | bytes] | None
default:"<class 'str'>"
Output destination for stdout.
str | Path | Writable | AsyncWritable | Literal[-1] | type[str | bytes] | None
default:"<class 'str'>"
Output destination for stderr.
str | None
default:"None"
Tag for the resulting image.
list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | UploadFileSpec] | None
default:"None"
Files to upload into the image.
float | timedelta | None
default:"None"
Execution timeout in seconds or as timedelta.
bool
default:"True"
If True, image is discarded after execution.
int | None
default:"None"
number of bytes to truncate stdout and stderr. Defaults to default_truncate_output_at
bool
default:"False"
If True, environment variables are preserved in resulting image after execution.
TypeVar(_T, bound= _ImageLikeBase)
New image instance configured for execution.
DisposableImageRunError – If attempting to run on a disposed image.
ValueError – If neither command nor shell is provided.

session()

ContreeSession

start()

Start the prepared command without waiting for completion.
TypeVar(_T, bound= _ImageLikeBase)
New image instance in EXECUTING state; await it or iterate its output chunks to get the result.

tag_as()

Tag this image with the specified tag, or remove the tag if None.
str | None
required
Tag name to apply to the image, or None to remove the tag.
TypeVar(_T, bound= _ImageLikeBase)
New instance with updated tag.

untag()

Remove the tag from this image.
TypeVar(_T, bound= _ImageLikeBase)
New instance with tag set to None.

class ContreeImageSync

Attributes

timedelta
Time elapsed during execution.
int
Exit code of the executed command.
ContreeResult
Execution result. Only available after successful execution.
ImageState
Current state of the image in the execution lifecycle.
str | bytes | Path | Writable | AsyncWritable | None
Stderr output from the execution.
str | bytes | Path | Readable | AsyncReadable | None
Configured stdin source.
str | bytes | Path | Writable | AsyncWritable | None
Stdout output from the execution.
UUID | None
Unique identifier of the image.
str | None
Optional tag associated with the image.

Methods

apply_files()

Upload files into a new image derived from this one.
str | Path | UploadFileSpec | list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | UploadFileSpec]
Files to upload.
list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | 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.
TypeVar(_T, bound= _ImageLikeBase)
New image with the uploaded files baked in.

download()

Download a file from the image to local filesystem.
str | PurePosixPath
required
Path to the file inside the image.
str | Path | None
default:"None"
Local destination path. Defaults to filename from image_path.
Path | None
Path to the downloaded file.

ls()

List files and directories at the given path.
str | PurePosixPath
default:"'/'"
Path inside the image to list.
list[ImageFileSync | ImageDirectorySync]
list[ImageFileSync | ImageDirectorySync]List of ImageFileSync and ImageDirectorySync objects.

popen()

Run a command with subprocess-like interface.
list[str] | str | None
default:"None"
Command and arguments list.
str | bytes | Path | Readable | AsyncReadable | None
default:"None"
Input source.
str | bytes | Path | Readable | AsyncReadable | None
default:"None"
Alternative input source (alias for stdin).
str | Path | Writable | AsyncWritable | Literal[-1] | type[str | bytes] | None
default:"None"
Output destination for stdout.
str | Path | Writable | AsyncWritable | Literal[-1] | type[str | bytes] | None
default:"None"
Output destination for stderr.
bool
default:"False"
If True, treat args as shell command.
str | None
default:"None"
Working directory inside the image.
float | None
default:"None"
Execution timeout in seconds.
bool
default:"False"
If True, raise on non-zero exit code.
bool | None
default:"None"
If True, decode output as text.
dict[str, str] | None
default:"None"
Environment variables.
ContreeProcessSync
ContreeProcessSyncContreeProcessSync object with execution results.

read()

Read file contents from the image.
str | PurePosixPath
required
Path to the file inside the image.
bytes
File contents as bytes.

run()

Prepare image for command execution.
str | None
default:"None"
Command to execute (mutually exclusive with shell).
str | None
default:"None"
Shell command string (mutually exclusive with command).
Iterable[str] | None
default:"None"
Command arguments.
dict[str, str] | None
default:"None"
Environment variables.
str | None
default:"None"
Working directory inside the image.
str | None
default:"None"
Hostname for the container.
str | bytes | Path | Readable | AsyncReadable | None
default:"None"
Input source.
str | Path | Writable | AsyncWritable | Literal[-1] | type[str | bytes] | None
default:"<class 'str'>"
Output destination for stdout.
str | Path | Writable | AsyncWritable | Literal[-1] | type[str | bytes] | None
default:"<class 'str'>"
Output destination for stderr.
str | None
default:"None"
Tag for the resulting image.
list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | UploadFileSpec] | None
default:"None"
Files to upload into the image.
float | timedelta | None
default:"None"
Execution timeout in seconds or as timedelta.
bool
default:"True"
If True, image is discarded after execution.
int | None
default:"None"
number of bytes to truncate stdout and stderr. Defaults to default_truncate_output_at
bool
default:"False"
If True, environment variables are preserved in resulting image after execution.
TypeVar(_T, bound= _ImageLikeBase)
New image instance configured for execution.
DisposableImageRunError – If attempting to run on a disposed image.
ValueError – If neither command nor shell is provided.

session()

ContreeSessionSync

start()

Start the prepared command without waiting for completion.
TypeVar(_T, bound= _ImageLikeBase)
New image instance in EXECUTING state; await it or iterate its output chunks to get the result.

tag_as()

Tag this image with the specified tag, or remove the tag if None.
str | None
required
Tag name to apply to the image, or None to remove the tag.
TypeVar(_T, bound= _ImageLikeBase)
New instance with updated tag.

untag()

Remove the tag from this image.
TypeVar(_T, bound= _ImageLikeBase)
New instance with tag set to None.

wait()

Execute the prepared command and wait for completion.
TypeVar(_T, bound= _ImageLikeSync)
New image instance with execution results.