Cmd Module#
- expectmine.utils.cmd.run_cmd(cmd: str, options: list[tuple[str, str] | str] | None = None) tuple[int, str, str][source]#
Runs a command and options in the command line. Returns three values, the result status code, a string of the cmd output and a string containing the error message if any is produced during execution.
- Parameters:
cmd (str) β The base command to run.
options (Optional[list[tuple[str, str] | str]]) β List of options added to the command. Options can be either arguments or tuples of option followed by the argument.
- Example:
>>> run_cmd("ls", ["-lh", "foo.bar"]) 0, "...", ""
>>> run_cmd(None , ["-lh", "*"]) TypeError("Cmd needs to be of type str.")
- Raises:
TypeError β If the arguments have the wrong type.
- expectmine.utils.cmd.validate_cmd(cmd: str, options: list[tuple[str, str] | str] | None = None)[source]#
Validates the cmd parameters.
- Parameters:
cmd (str) β The base command to run.
options (Optional[list[tuple[str, str] | str]]) β List of options added to the command. Options can be either arguments or tuples of option followed by the argument.
- Example:
>>> validate_cmd("ls", ["-lh", "*"])
>>> validate_cmd(None , ["-lh", "*"]) TypeError("Cmd needs to be of type str.")
- Raises:
TypeError β If the arguments have the wrong type.