Command#

class nublado.startup.storage.command.Command(*, capture_output=True, ignore_fail=False, text=True, logger=None)#

Bases: object

Wrapper around executing external commands.

This class provides a generic wrapper around subprocess that is helpful for executing external commands, checking their status, and optionally capturing their output in a consistent way.

It represents a slight simplification of the standard ~subprocess.run() function. It is intended for use by storage classes that perform operations via external commands, which are expected to constrain the arguments to the command and the parameters to the run() call.

Parameters:

Methods Summary

run(*args[, cwd, env, timeout])

Run the command with the provided arguments.

Methods Documentation

run(*args, cwd=None, env=None, timeout=None)#

Run the command with the provided arguments.

Parameters:
  • *args (str) – Arguments to the command. The first argument is the command itself, and if not fully-qualified must exist somewhere in the caller’s PATH.

  • cwd (Optional[Path], default: None) – If provided, change working directories to this path before running the command.

  • env (Optional[dict[str, str]], default: None) – If provided, use this dictionary as the process environment. If not, use the caller’s process environment.

  • timeout (Union[timedelta, float, None], default: None) – If given, the command will be terminated and a CommandTimedOutError will be raised if execution time exceeds this timeout.

Raises:
Return type:

CompletedProcess