diff options
author | Thomas Kluyver <takowl@gmail.com> | 2015-10-03 12:55:41 +0100 |
---|---|---|
committer | Thomas Kluyver <takowl@gmail.com> | 2015-10-03 12:55:41 +0100 |
commit | 823ad5164891ba148cc6857dc1400dedd1e78693 (patch) | |
tree | 7fe16736bce26749d4f3641e16d45f904e39e8c6 /doc | |
parent | 6d68b93dd1e7e548bc51bee0edf6584efd5d833a (diff) | |
download | pexpect-git-823ad5164891ba148cc6857dc1400dedd1e78693.tar.gz |
Update docs for PopenSpawn and Windows support
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/fdpexpect.rst | 12 | ||||
-rw-r--r-- | doc/api/index.rst | 1 | ||||
-rw-r--r-- | doc/api/popen_spawn.rst | 24 | ||||
-rw-r--r-- | doc/history.rst | 7 | ||||
-rw-r--r-- | doc/install.rst | 7 | ||||
-rw-r--r-- | doc/overview.rst | 17 |
6 files changed, 55 insertions, 13 deletions
diff --git a/doc/api/fdpexpect.rst b/doc/api/fdpexpect.rst index 8321454..3ddf2cd 100644 --- a/doc/api/fdpexpect.rst +++ b/doc/api/fdpexpect.rst @@ -13,10 +13,8 @@ fdspawn class .. automethod:: isalive .. automethod:: close - .. note:: - :class:`fdspawn` inherits all of the methods of :class:`~pexpect.spawn`, - but not all of them can be used, especially if the file descriptor is not - a terminal. Some methods may do nothing (e.g. :meth:`~fdspawn.kill`), while - others will raise an exception (e.g. :meth:`~fdspawn.terminate`). - This behaviour might be made more consistent in the future, so try to - avoid relying on it.
\ No newline at end of file + .. method:: expect + expect_exact + expect_list + + As :class:`pexpect.spawn`. diff --git a/doc/api/index.rst b/doc/api/index.rst index fd017a5..5277d1c 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -6,6 +6,7 @@ API documentation pexpect fdpexpect + popen_spawn replwrap pxssh diff --git a/doc/api/popen_spawn.rst b/doc/api/popen_spawn.rst new file mode 100644 index 0000000..64cae15 --- /dev/null +++ b/doc/api/popen_spawn.rst @@ -0,0 +1,24 @@ +popen_spawn - use pexpect with a piped subprocess +================================================= + +.. automodule:: pexpect.popen_spawn + +PopenSpawn class +---------------- + +.. autoclass:: PopenSpawn + + .. automethod:: __init__ + .. automethod:: send + .. automethod:: sendline + .. automethod:: write + .. automethod:: writelines + .. automethod:: kill + .. automethod:: sendeof + .. automethod:: wait + + .. method:: expect + expect_exact + expect_list + + As :class:`pexpect.spawn`. diff --git a/doc/history.rst b/doc/history.rst index b33e4d9..1167865 100644 --- a/doc/history.rst +++ b/doc/history.rst @@ -7,14 +7,15 @@ Releases Version 4.0 ``````````` -* Integration with :mod:`asyncio`: passing ``async=True`` to :meth:`~.expect`, - :meth:`~.expect_exact` or :meth:`~.expect_list` will make them return a +* Integration with :mod:`asyncio`: passing ``async=True`` to :meth:`~.spawn.expect`, + :meth:`~.spawn.expect_exact` or :meth:`~.spawn.expect_list` will make them return a coroutine. You can get the result using ``yield from``, or wrap it in an :class:`asyncio.Task`. This allows the event loop to do other things while waiting for output that matches a pattern. +* Experimental support for Windows (with some caveats)—see :ref:`windows`. * Enhancement: allow method as callbacks of argument ``events`` for :func:`pexpect.run` (:ghissue:`176`). -* It is now possible to call :meth:`~.wait` multiple times, or after a process +* It is now possible to call :meth:`~.spawn.wait` multiple times, or after a process is already determined to be terminated without raising an exception (:ghpull:`211`). * New :class:`pexpect.spawn` keyword argument, ``dimensions=(rows, columns)`` diff --git a/doc/install.rst b/doc/install.rst index 297acf3..d310871 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -15,6 +15,7 @@ Requirements This version of Pexpect requires Python 2.6 or 3.2 or above. For older versions of Python, continue using Pexpect 2.4. -Pexpect only works on POSIX systems, where the :mod:`pty` module -is present in the standard library. It may be possible to run it on Windows -using `Cygwin <http://www.cygwin.com/>`_. +As of version 4.0, Pexpect can be used on Windows and POSIX systems. However, +:class:`pexpect.spawn` and :func:`pexpect.run` are only available on POSIX, +where the :mod:`pty` module is present in the standard library. See +:ref:`windows` for more information. diff --git a/doc/overview.rst b/doc/overview.rst index c5bcb05..d394ef1 100644 --- a/doc/overview.rst +++ b/doc/overview.rst @@ -238,3 +238,20 @@ You can have these methods ignore timeout and block indefinitely by passing ``None`` for the timeout parameter:: child.expect(pexpect.EOF, timeout=None) + +.. _windows: + +Pexpect on Windows +------------------ + +.. versionadded:: 4.0 + Windows support + +Pexpect can be used on Windows to wait for a pattern to be produced by a child +process, using :class:`pexpect.popen_spawn.PopenSpawn`, or a file descriptor, +using :class:`pexpect.fdpexpect.fdspawn`. This should be considered experimental +for now. + +:class:`pexpect.spawn` and :func:`pexpect.run` are *not* available on Windows, +as they rely on Unix pseudoterminals (ptys). Cross platform code must not use +these. |