[Python-modules-commits] [pexpect] 01/01: Import pexpect_4.0.1.orig.tar.gz
Javier Merino Cacho
vicho at moszumanska.debian.org
Sun Nov 1 19:21:24 UTC 2015
This is an automated email from the git hooks/post-receive script.
vicho pushed a commit to branch upstream
in repository pexpect.
commit f079872e07a7c1f13368fa46b24351fbefd0f501
Author: Javi Merino <vicho at debian.org>
Date: Sun Nov 1 17:15:38 2015 +0000
Import pexpect_4.0.1.orig.tar.gz
---
ANSI.py | 7 -
FSM.py | 7 -
INSTALL | 48 -
LICENSE | 2 +
PKG-INFO | 12 +-
doc/FAQ.rst | 43 +-
doc/api/ANSI.rst | 14 -
doc/api/fdpexpect.rst | 12 +-
doc/api/index.rst | 11 +-
doc/api/pexpect.rst | 32 +-
doc/api/popen_spawn.rst | 24 +
doc/api/pxssh.rst | 4 +
doc/api/replwrap.rst | 26 +
doc/api/screen.rst | 10 -
doc/commonissues.rst | 28 +-
doc/conf.py | 4 +-
doc/history.rst | 64 +-
doc/install.rst | 10 +-
doc/overview.rst | 29 +-
doc/requirements.txt | 1 +
examples/astat.py | 7 +-
examples/cgishell.cgi | 4 +-
examples/chess.py | 3 +-
examples/chess2.py | 4 +-
examples/chess3.py | 3 +-
examples/hive.py | 1 -
fdpexpect.py | 7 -
pexpect/ANSI.py | 66 +-
pexpect/__init__.py | 1983 +-------------------
pexpect/async.py | 72 +
pexpect/exceptions.py | 35 +
pexpect/expect.py | 297 +++
pexpect/fdpexpect.py | 51 +-
pexpect/popen_spawn.py | 179 ++
pexpect/psh.py | 148 --
pexpect/pty_spawn.py | 824 ++++++++
pexpect/pxssh.py | 28 +-
pexpect/replwrap.py | 113 ++
pexpect/run.py | 157 ++
pexpect/screen.py | 109 +-
pexpect/spawnbase.py | 488 +++++
pexpect/utils.py | 112 ++
pxssh.py | 7 -
screen.py | 7 -
setup.cfg | 2 +
setup.py | 26 +-
test.env | 28 -
tests/PexpectTestCase.py | 76 +-
tests/README | 18 +-
tests/depricated_test_filedescriptor.py | 1 -
tests/echo_w_prompt.py | 8 +-
tests/echo_wait.py | 4 +-
tests/getch.py | 6 +-
tests/interact.py | 20 +-
tests/interact_unicode.py | 20 -
tests/log | 10 +
tests/pexpectTest.py | 4 +-
.../CSIGNALTEST/test.c | 0
tests/platform_checks/README | 2 +
.../test.py => platform_checks/check.py} | 5 +-
.../test2.py => platform_checks/check2.py} | 4 +-
.../check_control_terminal.py} | 0
.../check_handler.py} | 8 +-
.../test_read.py => platform_checks/check_read.py} | 2 +-
.../check_signals.py} | 6 +-
tests/platform_tests/README | 4 -
tests/platform_tests/pexqa.py | 39 -
tests/platform_tests/test_badfork.py | 15 -
tests/platform_tests/test_killed_pid.py | 17 -
tests/platform_tests/test_middle_buffer.py | 30 -
tests/sigwinch_report.py | 1 +
tests/test_ansi.py | 94 +-
tests/test_async.py | 51 +
tests/test_command_list_split.py | 3 +-
tests/test_constructor.py | 13 +-
tests/test_ctrl_chars.py | 105 +-
tests/test_destructor.py | 2 +-
tests/test_dotall.py | 2 +-
tests/test_expect.py | 210 ++-
tests/test_filedescriptor.py | 28 +-
tests/test_interact.py | 95 +-
tests/test_isalive.py | 119 +-
tests/test_log.py | 2 +-
tests/test_maxcanon.py | 176 ++
tests/test_misc.py | 458 ++---
tests/test_missing_command.py | 2 +-
tests/test_performance.py | 19 +-
tests/test_popen_spawn.py | 131 ++
tests/test_psh.py | 16 -
tests/test_replwrap.py | 105 ++
tests/test_repr.py | 26 +
tests/test_run.py | 152 +-
tests/test_run_out_of_pty.py | 2 +-
tests/test_screen.py | 126 +-
tests/test_timeout_pattern.py | 2 +-
tests/test_unicode.py | 58 +-
tests/test_which.py | 274 +++
tests/test_winsize.py | 61 +-
tests/utils.py | 7 +
tools/testall.py | 89 -
100 files changed, 4642 insertions(+), 3235 deletions(-)
diff --git a/ANSI.py b/ANSI.py
deleted file mode 100644
index ca1673b..0000000
--- a/ANSI.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import warnings
-
-warnings.warn("This module has been moved to pexpect.ANSI, please update imports.",
- ImportWarning)
-del warnings
-
-from pexpect.ANSI import * # analysis:ignore
\ No newline at end of file
diff --git a/FSM.py b/FSM.py
deleted file mode 100644
index 4e1ab49..0000000
--- a/FSM.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import warnings
-
-warnings.warn("This module has been moved to pexpect.FSM, please update imports.",
- ImportWarning)
-del warnings
-
-from pexpect.FSM import * # analysis:ignore
\ No newline at end of file
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index c3a2c65..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,48 +0,0 @@
-Installation
-------------
-This is a standard Python Distutil distribution. To install simply run:
-
- python setup.py install
-
-This makes Pexpect available to any script on the machine. You need
-root access to install it this way. If you do not have root access or
-if you do not wish to install Pexpect so that is available to any script
-then you can just copy the pexpect.py file to same directory as your script.
-
-Trouble on Debian and Ubuntu
-----------------------------
-For some stupid reason Debian Linux does not include the distutils module
-in the standard 'python' package. Instead, the distutils module is packaged
-separately in the 'python-dev' package. So to add distutils back
-into Python, simply use aptitude or apt-get to install 'python-dev'.
-As root, run this command:
- apt-get install python-dev
-Why they do this is mysterious because:
- - It breaks the Python model of "batteries included".
- 'distutils' isn't an extra or optional module --
- it's parts of the Standard Python Library.
- - The Debian 'python-dev' package is a microscopic 50K installed.
- So what are they saving?
- - Distutils is not only interesting to developers. Many non-development
- oriented Python packages use 'distutils' to install applications.
- - As far as I can tell, the package maintainers must go through
- more trouble to remove 'distutils' from the standard Python
- distribution than it would take just to leave it in.
-
-PEXPECT LICENSE
-
- This license is approved by the OSI and FSF as GPL-compatible.
- http://opensource.org/licenses/isc-license.txt
-
- Copyright (c) 2012, Noah Spurrier <noah at noah.org>
- PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY
- PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE
- COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES.
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
diff --git a/LICENSE b/LICENSE
index 18ff9db..9e10acb 100644
--- a/LICENSE
+++ b/LICENSE
@@ -3,7 +3,9 @@ PEXPECT LICENSE
This license is approved by the OSI and FSF as GPL-compatible.
http://opensource.org/licenses/isc-license.txt
+ Copyright (c) 2013-2014, Pexpect development team
Copyright (c) 2012, Noah Spurrier <noah at noah.org>
+
PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY
PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE
COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES.
diff --git a/PKG-INFO b/PKG-INFO
index 6a14749..6647aad 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: pexpect
-Version: 3.2
+Version: 4.0.1
Summary: Pexpect allows easy control of interactive console applications.
Home-page: http://pexpect.readthedocs.org/
Author: Noah Spurrier; Thomas Kluyver; Jeff Quast
@@ -16,10 +16,12 @@ Description:
passwd, telnet, etc. It can be used to a automate setup scripts for duplicating
software package installations on different servers. It can be used for
automated software testing. Pexpect is in the spirit of Don Libes' Expect, but
- Pexpect is pure Python. Unlike other Expect-like modules for Python, Pexpect
- does not require TCL or Expect nor does it require C extensions to be compiled.
- It should work on any platform that supports the standard Python pty module.
- The Pexpect interface was designed to be easy to use.
+ Pexpect is pure Python.
+
+ The main features of Pexpect require the pty module in the Python standard
+ library, which is only available on Unix-like systems. Some features—waiting
+ for patterns from file descriptors or subprocesses—are also available on
+ Windows.
Platform: UNIX
Classifier: Development Status :: 5 - Production/Stable
diff --git a/doc/FAQ.rst b/doc/FAQ.rst
index bec1c35..1964b12 100644
--- a/doc/FAQ.rst
+++ b/doc/FAQ.rst
@@ -1,6 +1,17 @@
FAQ
===
+**Q: Where can I get help with pexpect? Is there a mailing list?**
+
+A: You can use the `pexpect tag on Stackoverflow <http://stackoverflow.com/questions/tagged/pexpect>`__
+to ask questions specifically related to Pexpect. For more general Python
+support, there's the python-list_ mailing list, and the `#python`_
+IRC channel. Please refrain from using github for general
+python or systems scripting support.
+
+.. _python-list: https://mail.python.org/mailman/listinfo/python-list
+.. _#python: https://www.python.org/community/irc/
+
**Q: Why don't shell pipe and redirect (| and >) work when I spawn a command?**
A: Remember that Pexpect does NOT interpret shell meta characters such as
@@ -21,15 +32,6 @@ previous example::
child = pexpect.spawn('/bin/bash', ['-c', shell_cmd])
child.expect(pexpect.EOF)
-**Q: Isn't there already a Python Expect?**
-
-A: Yes, there are several of them. They usually require you to compile C.
-I wanted something that was pure Python and preferably a single module
-that was simple to install. I also wanted something that was easy to use.
-This pure Python expect only became possible with the introduction of
-the pty module in the standard Python library. Previously, C extensions
-were required.
-
**Q: The `before` and `after` properties sound weird.**
A: This is how the -B and -A options in grep works, so that made it
@@ -126,11 +128,18 @@ another application.
**Q: Can I do screen scraping with this thing?**
A: That depends. If your application just does line-oriented output then
-this is easy. If it does screen-oriented output then it may work, but it
-could be hard. For example, trying to scrape data from the 'top' command
-would be hard. The top command repaints the text window.
-
-I am working on an ANSI / VT100 terminal emulator that will have methods
-to get characters from an arbitrary X,Y coordinate of the virtual screen.
-It works and you can play with it (see :mod:`pexpect.ANSI`), but I have
-no working examples at this time.
+this is easy. If a program emits many terminal sequences, from video
+attributes to screen addressing, such as programs using curses, then
+it may become very difficult to ascertain what text is displayed on a screen.
+
+We suggest using the `pyte <https://github.com/selectel/pyte>`_ library to
+screen-scrape. The module :mod:`pexpect.ANSI` released with previous versions
+of pexpect is now marked deprecated and may be removed in the future.
+
+**Q: I get strange behavior with pexect and gevent**
+
+A: Pexpect uses fork(2), exec(2), select(2), waitpid(2), and implements its
+own selector in expect family of calls. pexpect has been known to misbehave
+when paired with gevent. A solution might be to isolate your pexpect
+dependent code from any frameworks that manipulate event selection behavior
+by running it in an another process entirely.
diff --git a/doc/api/ANSI.rst b/doc/api/ANSI.rst
deleted file mode 100644
index 064563d..0000000
--- a/doc/api/ANSI.rst
+++ /dev/null
@@ -1,14 +0,0 @@
-ANSI - ANSI (VT100) terminal emulator
-=====================================
-
-.. automodule:: pexpect.ANSI
-
-.. autoclass:: term
- :show-inheritance:
-
-.. autoclass:: ANSI
- :show-inheritance:
-
- .. automethod:: write_ch
- .. automethod:: write
- .. automethod:: process
\ No newline at end of file
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 b902131..5277d1c 100644
--- a/doc/api/index.rst
+++ b/doc/api/index.rst
@@ -6,6 +6,13 @@ API documentation
pexpect
fdpexpect
+ popen_spawn
+ replwrap
pxssh
- screen
- ANSI
\ No newline at end of file
+
+The modules ``pexpect.screen`` and ``pexpect.ANSI`` have been deprecated in
+Pexpect version 4. They were separate from the main use cases for Pexpect, and
+there are better maintained Python terminal emulator packages, such as
+`pyte <https://pypi.python.org/pypi/pyte>`__.
+These modules are still present for now, but we don't advise using them in new
+code.
diff --git a/doc/api/pexpect.rst b/doc/api/pexpect.rst
index 565f0ef..79bbcef 100644
--- a/doc/api/pexpect.rst
+++ b/doc/api/pexpect.rst
@@ -36,9 +36,9 @@ spawn class
.. note::
- With a :class:`spawn` instance, the log files should be open for
- writing binary data. With a :class:`spawnu` instance, they should
- be open for writing unicode text.
+ With :class:`spawn` in bytes mode, the log files should be open for
+ writing binary data. In unicode mode, they should
+ be open for writing unicode text. See :ref:`unicode`.
Controlling the child process
`````````````````````````````
@@ -69,31 +69,35 @@ Controlling the child process
Handling unicode
````````````````
-For backwards compatibility, :class:`spawn` can handle some Unicode: its
-send methods will encode arbitrary unicode as UTF-8 before sending it to the
-child process, and its expect methods can accept ascii-only unicode strings.
-However, for a proper unicode API to a subprocess, use this subclass:
+By default, :class:`spawn` is a bytes interface: its read methods return bytes,
+and its write/send and expect methods expect bytes. If you pass the *encoding*
+parameter to the constructor, it will instead act as a unicode interface:
+strings you send will be encoded using that encoding, and bytes received will
+be decoded before returning them to you. In this mode, patterns for
+:meth:`~spawn.expect` and :meth:`~spawn.expect_exact` should also be unicode.
+
+.. versionchanged:: 4.0
-.. autoclass:: spawnu
- :show-inheritance:
+ :class:`spawn` provides both the bytes and unicode interfaces. In Pexpect
+ 3.x, the unicode interface was provided by a separate ``spawnu`` class.
-There is also a :func:`runu` function, the unicode counterpart to :func:`run`.
+For backwards compatibility, some Unicode is allowed in bytes mode: the
+send methods will encode arbitrary unicode as UTF-8 before sending it to the
+child process, and its expect methods can accept ascii-only unicode strings.
.. note::
Unicode handling with pexpect works the same way on Python 2 and 3, despite
the difference in names. I.e.:
- - :class:`spawn` works with ``str`` on Python 2, and :class:`bytes` on Python 3,
- - :class:`spawnu` works with ``unicode`` on Python 2, and :class:`str` on Python 3.
+ - Bytes mode works with ``str`` on Python 2, and :class:`bytes` on Python 3,
+ - Unicode mode works with ``unicode`` on Python 2, and :class:`str` on Python 3.
run function
------------
.. autofunction:: run
-.. autofunction:: runu
-
Exceptions
----------
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/api/pxssh.rst b/doc/api/pxssh.rst
index 0b67839..b947f4b 100644
--- a/doc/api/pxssh.rst
+++ b/doc/api/pxssh.rst
@@ -23,6 +23,10 @@ pxssh class
server to ask for a password. Note that the sysadmin can disable password
logins, in which case this won't work.
+ .. attribute:: options
+
+ The dictionary of user specified SSH options, eg, ``options = dict(StrictHostKeyChecking="no", UserKnownHostsFile="/dev/null")``
+
.. automethod:: login
.. automethod:: logout
.. automethod:: prompt
diff --git a/doc/api/replwrap.rst b/doc/api/replwrap.rst
new file mode 100644
index 0000000..bf44a94
--- /dev/null
+++ b/doc/api/replwrap.rst
@@ -0,0 +1,26 @@
+replwrap - Control read-eval-print-loops
+========================================
+
+.. automodule:: pexpect.replwrap
+
+.. versionadded:: 3.3
+
+.. autoclass:: REPLWrapper
+
+ .. automethod:: run_command
+
+.. data:: PEXPECT_PROMPT
+
+ A string that can be used as a prompt, and is unlikely to be found in output.
+
+Using the objects above, it is easy to wrap a REPL. For instance, to use a
+Python shell::
+
+ py = REPLWrapper("python", ">>> ", "import sys; sys.ps1={!r}; sys.ps2={!r}")
+ py.run_command("4+7")
+
+Convenience functions are provided for Python and bash shells:
+
+.. autofunction:: python
+
+.. autofunction:: bash
diff --git a/doc/api/screen.rst b/doc/api/screen.rst
deleted file mode 100644
index 8268fb9..0000000
--- a/doc/api/screen.rst
+++ /dev/null
@@ -1,10 +0,0 @@
-screen - manage a virtual 'screen'
-==================================
-
-.. automodule:: pexpect.screen
-
-.. autoclass:: screen
- :members:
-
- .. automethod:: __init__
- .. automethod:: __str__
\ No newline at end of file
diff --git a/doc/commonissues.rst b/doc/commonissues.rst
index 2efae46..d3aa9d0 100644
--- a/doc/commonissues.rst
+++ b/doc/commonissues.rst
@@ -49,20 +49,6 @@ off::
child = pexpect.spawn ("ssh user at example.com")
child.delaybeforesend = 0
-Timing issue with isalive()
----------------------------
-
-Reading the state of :meth:`~pexpect.spawn.isalive` immediately after a child
-exits may sometimes return 1. This is a race condition. The child has closed its
-file descriptor, but has not yet fully exited before Pexpect's
-:meth:`~pexpect.spawn.isalive` executes. Addings a slight delay before the
-:meth:`~pexpect.spawn.isalive` call will help. For example::
-
- child = pexpect.spawn('ls')
- child.expect(pexpect.EOF)
- time.sleep(0.1)
- print child.isalive()
-
Truncated output just before child exits
----------------------------------------
@@ -89,7 +75,7 @@ sometimes will not allow TTY password authentication. For example, you may
expect SSH to ask you for a password using code like this::
child = pexpect.spawn('ssh user at example.com')
- child.expect('assword')
+ child.expect('password')
child.sendline('mypassword')
You may see the following error come back from a spawned child SSH::
@@ -101,3 +87,15 @@ The only solution I have found is to use public key authentication with SSH.
This bypasses the need for a password. I'm not happy with this solution. The
problem is due to poor support for Solaris Pseudo TTYs in the Python Standard
Library.
+
+child does not receive full input, emits BEL
+--------------------------------------------
+
+You may notice when running for example cat(1) or base64(1), when sending a
+very long input line, that it is not fully received, and the BEL ('\a') may
+be found in output.
+
+By default the child terminal matches the parent, which is often in "canonical
+mode processing". You may wish to disable this mode. The exact limit of a line
+varies by operating system, and details of disabling canonical mode may be
+found in the docstring of :meth:`~pexpect.spawn.send`.
diff --git a/doc/conf.py b/doc/conf.py
index a5b7088..8f9500f 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -52,9 +52,9 @@ copyright = u'2013, Noah Spurrier and contributors'
# built documents.
#
# The short X.Y version.
-version = '3.2'
+version = '4.0.1'
# The full version, including alpha/beta/rc tags.
-release = '3.2'
+release = '4.0.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/doc/history.rst b/doc/history.rst
index 57d2cdf..1167865 100644
--- a/doc/history.rst
+++ b/doc/history.rst
@@ -4,6 +4,66 @@ History
Releases
--------
+Version 4.0
+```````````
+
+* 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:`~.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)``
+ allows setting terminal screen dimensions before launching a program
+ (:ghissue:`122`).
+* Fix regression that prevented executable, but unreadable files from
+ being found when not specified by absolute path -- such as
+ /usr/bin/sudo (:ghissue:`104`).
+* Fixed regression when executing pexpect with some prior releases of
+ the multiprocessing module where stdin has been closed (:ghissue:`86`).
+
+Backwards incompatible changes
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+* Deprecated ``pexpect.screen`` and ``pexpect.ANSI``. Please use other packages
+ such as `pyte <https://pypi.python.org/pypi/pyte>`__ to emulate a terminal.
+* Removed the independent top-level modules (``pxssh fdpexpect FSM screen ANSI``)
+ which were installed alongside Pexpect. These were moved into the Pexpect
+ package in 3.0, but the old names were left as aliases.
+* Child processes created by Pexpect no longer ignore SIGHUP by default: the
+ ``ignore_sighup`` parameter of :class:`pexpect.spawn` defaults to False. To
+ get the old behaviour, pass ``ignore_sighup=True``.
+
+Version 3.3
+```````````
+
+* Added a mechanism to wrap REPLs, or shells, in an object which can conveniently
+ be used to send commands and wait for the output (:mod:`pexpect.replwrap`).
+* Fixed issue where pexpect would attempt to execute a directory because
+ it has the 'execute' bit set (:ghissue:`37`).
+* Removed the ``pexpect.psh`` module. This was never documented, and we found
+ no evidence that people use it. The new :mod:`pexpect.replwrap` module
+ provides a more flexible alternative.
+* Fixed ``TypeError: got <type 'str'> ('\r\n') as pattern`` in :meth:`spawnu.readline`
+ method (:ghissue:`67`).
+* Fixed issue where EOF was not correctly detected in :meth:`~.interact`, causing
+ a repeating loop of output on Linux, and blocking before EOF on BSD and
+ Solaris (:ghissue:`49`).
+* Several Solaris (SmartOS) bugfixes, preventing :exc:`IOError` exceptions, especially
+ when used with cron(1) (:ghissue:`44`).
+* Added new keyword argument ``echo=True`` for :class:`spawn`. On SVR4-like
+ systems, the method :meth:`~.isatty` will always return *False*: the child pty
+ does not appear as a terminal. Therefore, :meth:`~.setecho`, :meth:`~.getwinsize`,
+ :meth:`~.setwinsize`, and :meth:`~.waitnoecho` are not supported on those platforms.
+
+After this, we intend to start working on a bigger refactoring of the code, to
+be released as Pexpect 4. There may be more bugfix 3.x releases, however.
+
Version 3.2
```````````
@@ -99,11 +159,11 @@ Version 2.3
consistently on different platforms. Solaris is the most difficult to support.
* You can now put ``TIMEOUT`` in a list of expected patterns. This is just like
putting ``EOF`` in the pattern list. Expecting for a ``TIMEOUT`` may not be
- used as often as ``EOF``, but this makes Pexpect more consitent.
+ used as often as ``EOF``, but this makes Pexpect more consistent.
* Thanks to a suggestion and sample code from Chad J. Schroeder I added the ability
for Pexpect to operate on a file descriptor that is already open. This means that
Pexpect can be used to control streams such as those from serial port devices. Now,
- you just pass the integer file descriptor as the "command" when contsructing a
+ you just pass the integer file descriptor as the "command" when constructing a
spawn open. For example on a Linux box with a modem on ttyS1::
fd = os.open("/dev/ttyS1", os.O_RDWR|os.O_NONBLOCK|os.O_NOCTTY)
diff --git a/doc/install.rst b/doc/install.rst
index 297acf3..6f7e36a 100644
--- a/doc/install.rst
+++ b/doc/install.rst
@@ -12,9 +12,9 @@ Or::
Requirements
------------
-This version of Pexpect requires Python 2.6 or 3.2 or above. For older
-versions of Python, continue using Pexpect 2.4.
+This version of Pexpect requires Python 3.3 or above, or Python 2.7.
-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 133767f..d394ef1 100644
--- a/doc/overview.rst
+++ b/doc/overview.rst
@@ -17,7 +17,7 @@ Here is an example of Pexpect in action::
child.expect('ftp> ')
child.sendline('lcd /tmp')
child.expect('ftp> ')
- child.sendline('cd pub')
+ child.sendline('cd pub/OpenBSD')
child.expect('ftp> ')
child.sendline('get README')
child.expect('ftp> ')
@@ -60,7 +60,7 @@ Special EOF and TIMEOUT patterns
--------------------------------
There are two special patterns to match the End Of File (:class:`~pexpect.EOF`)
-or a Timeout condition (:class:`~pexpect.TIMEOUT`). You you can pass these
+or a Timeout condition (:class:`~pexpect.TIMEOUT`). You can pass these
patterns to :meth:`~pexpect.spawn.expect`. These patterns are not regular
expressions. Use them like predefined constants.
@@ -84,13 +84,13 @@ The following code fragment gives an example of this::
# We expect any of these three patterns...
i = child.expect (['Permission denied', 'Terminal type', '[#\$] '])
if i==0:
- print('Permission denied on host. Can't login')
+ print('Permission denied on host. Can\'t login')
child.kill(0)
- elif i==2:
+ elif i==1:
print('Login OK... need to send terminal type.')
child.sendline('vt100')
child.expect('[#\$] ')
- elif i==3:
+ elif i==2:
print('Login OK.')
print('Shell command prompt', child.after)
@@ -234,7 +234,24 @@ If you wish to read up to the end of the child's output without generating an
The :meth:`~pexpect.spawn.expect` and :meth:`~pexpect.spawn.read` methods will
also timeout if the child does not generate any output for a given amount of
time. If this happens they will raise a :class:`~pexpect.TIMEOUT` exception.
-You can have these method ignore a timeout and block indefinitely by passing
+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.
diff --git a/doc/requirements.txt b/doc/requirements.txt
new file mode 100644
index 0000000..57ebb2d
--- /dev/null
+++ b/doc/requirements.txt
@@ -0,0 +1 @@
+ptyprocess
diff --git a/examples/astat.py b/examples/astat.py
index ef5c3a9..a083fe1 100755
--- a/examples/astat.py
+++ b/examples/astat.py
@@ -34,8 +34,11 @@ from __future__ import print_function
from __future__ import absolute_import
-import os, sys, time, re, getopt, getpass
-import pexpect, pxssh
+import os
+import sys
+import getopt
+import getpass
+import pxssh
try:
diff --git a/examples/cgishell.cgi b/examples/cgishell.cgi
index b807a8b..23bef5f 100755
--- a/examples/cgishell.cgi
+++ b/examples/cgishell.cgi
@@ -176,11 +176,11 @@ def daemonize (stdin=None, stdout=None, stderr=None, daemon_pid_filename=None):
if stderr is None: stderr = DEVNULL
try:
- pid = os.fork()
+ pid = os.fork() # fork first child
except OSError as e:
raise Exception("%s [%d]" % (e.strerror, e.errno))
- if pid != 0: # The first child.
+ if pid != 0:
os.waitpid(pid,0)
if daemon_pid_filename is not None:
daemon_pid = int(file(daemon_pid_filename,'r').read())
diff --git a/examples/chess.py b/examples/chess.py
index 8e33d9b..421727d 100755
--- a/examples/chess.py
+++ b/examples/chess.py
@@ -27,7 +27,6 @@ from __future__ import print_function
from __future__ import absolute_import
import pexpect
-import string
import ANSI
REGEX_MOVE = '(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)'
@@ -95,7 +94,7 @@ class Chess:
def quit(self):
self.child.sendline ('quit')
-import sys, os
+import sys
print('Starting...')
white = Chess()
white.child.echo = 1
diff --git a/examples/chess2.py b/examples/chess2.py
index ae5fcea..b92509e 100755
--- a/examples/chess2.py
+++ b/examples/chess2.py
@@ -27,9 +27,9 @@ from __future__ import print_function
from __future__ import absolute_import
import pexpect
-import string
import ANSI
-import sys, os, time
+import sys
+import time
class Chess:
diff --git a/examples/chess3.py b/examples/chess3.py
index 5080dcb..dc02663 100755
--- a/examples/chess3.py
+++ b/examples/chess3.py
@@ -27,7 +27,6 @@ from __future__ import print_function
from __future__ import absolute_import
import pexpect
-import string
import ANSI
REGEX_MOVE = '(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)'
@@ -98,7 +97,7 @@ class Chess:
def quit(self):
self.child.sendline ('quit')
-import sys, os
+import sys
print('Starting...')
white = Chess()
white.do_move('b2b4')
diff --git a/examples/hive.py b/examples/hive.py
index 6edd9b0..00ddbea 100755
--- a/examples/hive.py
+++ b/examples/hive.py
@@ -88,7 +88,6 @@ import sys
import os
import re
import optparse
-import types
import time
import getpass
import readline
diff --git a/fdpexpect.py b/fdpexpect.py
deleted file mode 100644
index 26db4c1..0000000
--- a/fdpexpect.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import warnings
-
-warnings.warn("This module has been moved to pexpect.fdpexpect, please update imports.",
- ImportWarning)
-del warnings
-
-from pexpect.fdpexpect import * # analysis:ignore
\ No newline at end of file
diff --git a/pexpect/ANSI.py b/pexpect/ANSI.py
index c2f20fc..1cd2e90 100644
--- a/pexpect/ANSI.py
+++ b/pexpect/ANSI.py
@@ -186,18 +186,18 @@ class term (screen.screen):
provides a common base class for other terminals
such as an ANSI terminal. '''
- def __init__ (self, r=24, c=80):
+ def __init__ (self, r=24, c=80, *args, **kwargs):
- screen.screen.__init__(self, r,c)
+ screen.screen.__init__(self, r,c,*args,**kwargs)
class ANSI (term):
'''This class implements an ANSI (VT100) terminal.
It is a stream filter that recognizes ANSI terminal
escape sequences and maintains the state of a screen object. '''
- def __init__ (self, r=24,c=80):
+ def __init__ (self, r=24,c=80,*args,**kwargs):
- term.__init__(self,r,c)
+ term.__init__(self,r,c,*args,**kwargs)
#self.screen = screen (24,80)
self.state = FSM.FSM ('INIT',[self])
@@ -227,7 +227,7 @@ class ANSI (term):
self.state.add_transition ('J', 'ELB', DoEraseDown, 'INIT')
self.state.add_transition ('K', 'ELB', DoEraseEndOfLine, 'INIT')
self.state.add_transition ('r', 'ELB', DoEnableScroll, 'INIT')
- self.state.add_transition ('m', 'ELB', None, 'INIT')
+ self.state.add_transition ('m', 'ELB', self.do_sgr, 'INIT')
self.state.add_transition ('?', 'ELB', None, 'MODECRAP')
self.state.add_transition_list (string.digits, 'ELB', DoStartNumber, 'NUMBER_1')
self.state.add_transition_list (string.digits, 'NUMBER_1', DoBuildNumber, 'NUMBER_1')
@@ -241,16 +241,16 @@ class ANSI (term):
### It gets worse... the 'm' code can have infinite number of
### number;number;number before it. I've never seen more than two,
### but the specs say it's allowed. crap!
- self.state.add_transition ('m', 'NUMBER_1', None, 'INIT')
+ self.state.add_transition ('m', 'NUMBER_1', self.do_sgr, 'INIT')
### LED control. Same implementation problem as 'm' code.
- self.state.add_transition ('q', 'NUMBER_1', None, 'INIT')
+ self.state.add_transition ('q', 'NUMBER_1', self.do_decsca, 'INIT')
# \E[?47h switch to alternate screen
# \E[?47l restores to normal screen from alternate screen.
self.state.add_transition_list (string.digits, 'MODECRAP', DoStartNumber, 'MODECRAP_NUM')
self.state.add_transition_list (string.digits, 'MODECRAP_NUM', DoBuildNumber, 'MODECRAP_NUM')
- self.state.add_transition ('l', 'MODECRAP_NUM', None, 'INIT')
- self.state.add_transition ('h', 'MODECRAP_NUM', None, 'INIT')
+ self.state.add_transition ('l', 'MODECRAP_NUM', self.do_modecrap, 'INIT')
+ self.state.add_transition ('h', 'MODECRAP_NUM', self.do_modecrap, 'INIT')
#RM Reset Mode Esc [ Ps l none
self.state.add_transition (';', 'NUMBER_1', None, 'SEMICOLON')
@@ -264,21 +264,24 @@ class ANSI (term):
### It gets worse... the 'm' code can have infinite number of
### number;number;number before it. I've never seen more than two,
### but the specs say it's allowed. crap!
- self.state.add_transition ('m', 'NUMBER_2', None, 'INIT')
+ self.state.add_transition ('m', 'NUMBER_2', self.do_sgr, 'INIT')
### LED control. Same problem as 'm' code.
- self.state.add_transition ('q', 'NUMBER_2', None, 'INIT')
+ self.state.add_transition ('q', 'NUMBER_2', self.do_decsca, 'INIT')
self.state.add_transition (';', 'NUMBER_2', None, 'SEMICOLON_X')
# Create a state for 'q' and 'm' which allows an infinite number of ignored numbers
self.state.add_transition_any ('SEMICOLON_X', DoLog, 'INIT')
- self.state.add_transition_list (string.digits, 'SEMICOLON_X', None, 'NUMBER_X')
+ self.state.add_transition_list (string.digits, 'SEMICOLON_X', DoStartNumber, 'NUMBER_X')
+ self.state.add_transition_list (string.digits, 'NUMBER_X', DoBuildNumber, 'NUMBER_X')
self.state.add_transition_any ('NUMBER_X', DoLog, 'INIT')
- self.state.add_transition ('m', 'NUMBER_X', None, 'INIT')
- self.state.add_transition ('q', 'NUMBER_X', None, 'INIT')
- self.state.add_transition (';', 'NUMBER_2', None, 'SEMICOLON_X')
+ self.state.add_transition ('m', 'NUMBER_X', self.do_sgr, 'INIT')
+ self.state.add_transition ('q', 'NUMBER_X', self.do_decsca, 'INIT')
+ self.state.add_transition (';', 'NUMBER_X', None, 'SEMICOLON_X')
def process (self, c):
- """Process a single byte. Called by :meth:`write`."""
+ """Process a single character. Called by :meth:`write`."""
+ if isinstance(c, bytes):
+ c = self._decode(c)
self.state.process(c)
def process_list (self, l):
@@ -289,6 +292,8 @@ class ANSI (term):
"""Process text, writing it to the virtual screen while handling
ANSI escape codes.
"""
+ if isinstance(s, bytes):
+ s = self._decode(s)
for c in s:
self.process(c)
@@ -300,23 +305,21 @@ class ANSI (term):
position is moved forward with wrap-around, but no scrolling is done if
the cursor hits the lower-right corner of the screen. '''
+ if isinstance(ch, bytes):
+ ch = self._decode(ch)
+
#\r and \n both produce a call to cr() and lf(), respectively.
ch = ch[0]
- if ch == '\r':
+ if ch == u'\r':
self.cr()
return
- if ch == '\n':
+ if ch == u'\n':
self.crlf()
return
if ch == chr(screen.BS):
self.cursor_back()
return
... 8737 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pexpect.git
More information about the Python-modules-commits
mailing list