class Responder(StreamWatcher): (source)
Known subclasses: invoke.watchers.FailingResponder
A parameterizable object that submits responses to specific patterns. Commonly used to implement password auto-responds for things like ``sudo``. .. versionadded:: 1.0
Method | __init__ |
Imprint this `Responder` with necessary parameters. |
Method | pattern |
Generic "search for pattern in stream, using index" behavior. |
Method | submit |
Act on ``stream`` data, potentially returning responses. |
Instance Variable | index |
Undocumented |
Instance Variable | pattern |
Undocumented |
Instance Variable | response |
Undocumented |
invoke.watchers.FailingResponder
Imprint this `Responder` with necessary parameters. :param pattern: A raw string (e.g. ``r"\[sudo\] password for .*:"``) which will be turned into a regular expression. :param response: The string to submit to the subprocess' stdin when ``pattern`` is detected.
Generic "search for pattern in stream, using index" behavior. Used here and in some subclasses that want to track multiple patterns concurrently. :param str stream: The same data passed to ``submit``. :param str pattern: The pattern to search for. :param str index_attr: The name of the index attribute to use. :returns: An iterable of string matches. .. versionadded:: 1.0
invoke.watchers.StreamWatcher.submit
invoke.watchers.FailingResponder
Act on ``stream`` data, potentially returning responses. :param str stream: All data read on this stream since the beginning of the session. :returns: An iterable of ``str`` (which may be empty). .. versionadded:: 1.0