utils¶
- otto.utils.split_on_commas(values)¶
Split a string or list of strings on commas into a flat list.
- Parameters:¶
values – A single comma-separated string, or a list of such strings.
- Return type:¶
list[str]- Returns:¶
A flat list of the individual values.
>>> split_on_commas("a,b,c") ['a', 'b', 'c'] >>> split_on_commas(["a,b", "c,d"]) ['a', 'b', 'c', 'd'] >>> split_on_commas("single") ['single']
-
otto.utils.cli_exposed(fn=
None, *, name=None, help=None)¶ Mark a host coroutine method for auto-exposure as an
otto hostsubcommand.namedefaults to the method name with underscores dashed.Usable bare (
@cli_exposed) or called (@cli_exposed(name=..., help=...)).
- otto.utils.is_literal(value, literal_type)¶
Raise a TypeError if value is not a valid member of the Literal type.
- Return type:¶
TypeVar(T)
- class otto.utils.Status(value)¶
Bases:
EnumGeneral status enum for commands and tests.
>>> Status.Success <Status.Success: 0> >>> Status.Failed <Status.Failed: 1> >>> Status(0) is Status.Success True-
Success =
0¶
-
Failed =
1¶
-
Error =
2¶
-
Unstable =
3¶
-
Skipped =
4¶
- property is_ok : bool¶
True for statuses that should be treated as passing (Success, Skipped).
-
Success =
- class otto.utils.CommandStatus(command: str, output: str, status: Status, retcode: int)¶
Bases:
NamedTupleResult of a command execution on a host.
>>> result = CommandStatus("echo hi", "hi", Status.Success, 0) >>> result.status <Status.Success: 0> >>> result.retcode 0- command : --is-rst--:py:class:`str`¶
Command that was issued
- output : --is-rst--:py:class:`str`¶
Command output
- status : --is-rst--:py:class:`~otto.utils.Status`¶
Command status
- retcode : --is-rst--:py:class:`int`¶
Command shell retcode