launch.substitutions.command module

Module for the Command substitution.

class launch.substitutions.command.Command[source]

Bases: Substitution

Substitution that gets the output of a command as a string.

If the command is not found or fails a SubstitutionFailure error is raised. Behavior on stderr output is configurable, see constructor.

__init__(command: str | Path | Substitution | Iterable[str | Path | Substitution], *, on_stderr: str | Path | Substitution | Iterable[str | Path | Substitution] = 'fail') None[source]

Construct a command substitution.

Parameters:
  • command – command to be executed. The substitutions will be performed, and shlex.split will be used on the result.

  • on_stderr – specifies what to do when there is stderr output. Can be one of: - ‘fail’: raises SubstitutionFailere when stderr output is detected. - ‘ignore’: stderr output is ignored. - ‘warn’: The stderr output is ignored, but a warning is logged if detected. - ‘capture’: The stderr output will be captured, together with stdout. It can also be a substitution, that results in one of those four options.

property command: List[Substitution]

Getter for command.

describe() str[source]

Return a description of this substitution as a string.

property on_stderr: List[Substitution]

Getter for on_stderr.

classmethod parse(data: Sequence[str | Path | Substitution | Iterable[str | Path | Substitution]])[source]

Parse Command substitution.

perform(context: LaunchContext) str[source]

Perform the substitution by running the command and capturing its output.