utils

otto.utils.splitOnCommas(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.

>>> splitOnCommas("a,b,c")
['a', 'b', 'c']
>>> splitOnCommas(["a,b", "c,d"])
['a', 'b', 'c', 'd']
>>> splitOnCommas("single")
['single']
otto.utils.async_typer_command(f)
Return type:

Callable[[ParamSpec(P)], TypeVar(R)]

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: Enum

General 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).

class otto.utils.CommandStatus(command: str, output: str, status: Status, retcode: int)

Bases: NamedTuple

Result 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