serena.util.shell#


class ShellCommandResult(*, stdout, return_code, cwd, stderr=None)[source]#

Bases: BaseModel

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:
  • stdout (str)

  • return_code (int)

  • cwd (str)

  • stderr (str | None)

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

execute_shell_command(command, cwd=None, capture_stderr=False)[source]#

Execute a shell command and return the output.

Parameters:
  • command (str) – The command to execute.

  • cwd (str | None) – The working directory to execute the command in. If None, the current working directory will be used.

  • capture_stderr (bool) – Whether to capture the stderr output.

Returns:

The output of the command.

Return type:

ShellCommandResult