Executing Commands

The ContainerManager may also be used to send arbitrary shell commands to its containers via its exec method, shown below.

outcome = client_bugzoo.containers.exec(container,
                                        command,
                                        context,
                                        stdout=True,
                                        stderr=False,
                                        time_limit=300)

A concise description of the outcome of the command execution is returned in the form of a ExecResponse object.

API Reference

class ContainerManager[source]
exec(container: bugzoo.core.container.Container, command: str, context: Optional[str] = None, stdout: bool = True, stderr: bool = False, time_limit: Optional[int] = None) → bugzoo.cmd.ExecResponse[source]

Executes a given command inside a provided container.

Parameters
  • container – the container to which the command should be issued.

  • command – the command that should be executed.

  • context – the working directory that should be used to perform the execution. If no context is provided, then the command will be executed at the root of the container.

  • stdout – specifies whether or not output to the stdout should be included in the execution summary.

  • stderr – specifies whether or not output to the stderr should be included in the execution summary.

  • time_limit – an optional time limit that is applied to the execution. If the command fails to execute within the time limit, the command will be aborted and treated as a failure.

Returns

a summary of the outcome of the execution.

Raises

KeyError – if the container no longer exists on the server.

class ExecResponse[source]

Used to hold the response from a command execution.

code → int

The exit code of the execution.

duration → float

The length of time taken to complete the execution.

output → str

The output of the execution.

to_dict() → dict[source]
static from_dict(d: dict) → bugzoo.cmd.ExecResponse[source]