class documentation

class Result: (source)

Known subclasses: invoke.runners.Promise

View In Hierarchy

A container for information about the result of a command execution. All params are exposed as attributes of the same name and type. :param str stdout: The subprocess' standard output. :param str stderr: Same as ``stdout`` but containing standard error (unless the process was invoked via a pty, in which case it will be empty; see `.Runner.run`.) :param str encoding: The string encoding used by the local shell environment. :param str command: The command which was executed. :param str shell: The shell binary used for execution. :param dict env: The shell environment used for execution. (Default is the empty dict, ``{}``, not ``None`` as displayed in the signature.) :param int exited: An integer representing the subprocess' exit/return code. .. note:: This may be ``None`` in situations where the subprocess did not run to completion, such as when auto-responding failed or a timeout was reached. :param bool pty: A boolean describing whether the subprocess was invoked with a pty or not; see `.Runner.run`. :param tuple hide: A tuple of stream names (none, one or both of ``('stdout', 'stderr')``) which were hidden from the user when the generating command executed; this is a normalized value derived from the ``hide`` parameter of `.Runner.run`. For example, ``run('command', hide='stdout')`` will yield a `Result` where ``result.hide == ('stdout',)``; ``hide=True`` or ``hide='both'`` results in ``result.hide == ('stdout', 'stderr')``; and ``hide=False`` (the default) generates ``result.hide == ()`` (the empty tuple.) .. note:: `Result` objects' truth evaluation is equivalent to their `.ok` attribute's value. Therefore, quick-and-dirty expressions like the following are possible:: if run("some shell command"): do_something() else: handle_problem() However, remember `Zen of Python #2 <http://zen-of-python.info/explicit-is-better-than-implicit.html#2>`_. .. versionadded:: 1.0

Method __bool__ Undocumented
Method __init__ Undocumented
Method __repr__ Undocumented
Method __str__ Undocumented
Method tail Return the last ``count`` lines of ``stream``, plus leading whitespace.
Instance Variable command Undocumented
Instance Variable encoding Undocumented
Instance Variable env Undocumented
Instance Variable exited Undocumented
Instance Variable hide Undocumented
Instance Variable pty Undocumented
Instance Variable shell Undocumented
Instance Variable stderr Undocumented
Instance Variable stdout Undocumented
Property failed The inverse of ``ok``.
Property ok A boolean equivalent to ``exited == 0``.
Property return_code An alias for ``.exited``.
def __bool__(self): (source)

Undocumented

def __init__(self, stdout='', stderr='', encoding=None, command='', shell='', env=None, exited=0, pty=False, hide=tuple()): (source)

Undocumented

def __repr__(self): (source)

Undocumented

def __str__(self): (source)

Undocumented

def tail(self, stream, count=10): (source)

Return the last ``count`` lines of ``stream``, plus leading whitespace. :param str stream: Name of some captured stream attribute, eg ``"stdout"``. :param int count: Number of lines to preserve. .. versionadded:: 1.3

Undocumented

encoding = (source)

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented

The inverse of ``ok``. I.e., ``True`` if the program exited with a nonzero return code, and ``False`` otherwise. .. versionadded:: 1.0

A boolean equivalent to ``exited == 0``. .. versionadded:: 1.0

@property
return_code = (source)

An alias for ``.exited``. .. versionadded:: 1.0