summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRed_M <1468433+Red-M@users.noreply.github.com>2018-05-20 19:04:39 +1000
committerGitHub <noreply@github.com>2018-05-20 19:04:39 +1000
commitf8db03098412006e21e7d5ec1ed0d453c3d749ce (patch)
tree3cebba04f442d4a9a6e347384613931ab93f78a6
parent4dad43c1335a0b77062eccd50c2b92e6db6d8cf5 (diff)
parent4507924a1ebd8b0677a0f67cb1f67eb531221241 (diff)
downloadpexpect-git-f8db03098412006e21e7d5ec1ed0d453c3d749ce.tar.gz
Merge pull request #6 from pexpect/master
update
-rw-r--r--doc/history.rst49
-rw-r--r--doc/overview.rst3
-rw-r--r--pexpect/fdpexpect.py2
-rw-r--r--pexpect/pty_spawn.py13
-rw-r--r--pexpect/utils.py8
5 files changed, 40 insertions, 35 deletions
diff --git a/doc/history.rst b/doc/history.rst
index d769e87..aaaaa5d 100644
--- a/doc/history.rst
+++ b/doc/history.rst
@@ -7,29 +7,32 @@ Releases
Version 4.5
```````````
-* :class:`~.spawn` + :class:`~.fdspawn` now have an ``use_poll`` parameter.
- This change allows the use of select.poll() on file descriptors.
- It allows for > 1024 file descriptors on the system, and, it is not used by
- default due to compatibility concerns and must be explicitly enabled.
-* :mod:`pexpect.pxssh` now has several new options in :meth:`pxssh.pxssh.login`.
-* :meth:`pxssh.pxssh.login` has the option ``password_regex`` which allows changing
- the password prompt regex for servers that include ``password:`` somewhere before a
- command line is reached.(:ghpull:`468`)
-* :meth:`pxssh.pxssh.login` now allows for setting up SSH tunnels to be requested once
- logged in to the remote server. This option is ``ssh_tunnels`` (:ghpull:`473`)
- The structure should be like this::
-
- { 'local': ['2424:localhost:22'], # Local SSH tunnels
- 'remote': ['2525:localhost:22'], # Remote SSH tunnels
- 'dynamic': [8888] } # Dynamic/SOCKS tunnels
-
-* :meth:`pxssh.pxssh.login` ``spawn_local_ssh`` allows subsequent logins from the remote session and treats
- the session as if it was local. Simply set this to ``False``. (:ghpull:`472`)
-* :meth:`pxssh.pxssh.login` ``sync_original_prompt`` can allow the prompt to not be set to something unique
- incase the remote server is sensetive to new lines at login. Set this to ``False`` to do so. (:ghpull:`468`)
-* :meth:`pxssh.pxssh.login` has had a change with the SSH key option, which is
- if ``ssh_key`` is set to ``True`` then the SSH client forces forwarding the authentication
- agent to the remote server instead of providing a key. (:ghpull:`473`)
+* :class:`~.spawn` and :class:`~.fdspawn` now have a ``use_poll`` parameter.
+ If this is True, they will use :func:`select.poll` instead of :func:`select.select`.
+ ``poll()`` allows file descriptors above 1024, but it must be explicitly
+ enabled due to compatibility concerns (:ghpull:`474`).
+* The :meth:`.pxssh.login` method has several new and changed options:
+
+ * The option ``password_regex`` allows changing
+ the password prompt regex, for servers that include ``password:`` in a banner
+ before reaching a prompt (:ghpull:`468`).
+ * :meth:`~.pxssh.login` now allows for setting up SSH tunnels to be requested once
+ logged in to the remote server. This option is ``ssh_tunnels`` (:ghpull:`473`).
+ The structure should be like this::
+
+ {
+ 'local': ['2424:localhost:22'], # Local SSH tunnels
+ 'remote': ['2525:localhost:22'], # Remote SSH tunnels
+ 'dynamic': [8888], # Dynamic/SOCKS tunnels
+ }
+
+ * The option ``spawn_local_ssh=False`` allows subsequent logins from the
+ remote session and treats the session as if it was local (:ghpull:`472`).
+ * Setting ``sync_original_prompt=False`` will prevent changing the prompt to
+ something unique, in case the remote server is sensitive to new lines at login
+ (:ghpull:`468`).
+ * If ``ssh_key=True`` is passed, the SSH client forces forwarding the authentication
+ agent to the remote server instead of providing a key (:ghpull:`473`).
Version 4.4
```````````
diff --git a/doc/overview.rst b/doc/overview.rst
index eca8565..e52809c 100644
--- a/doc/overview.rst
+++ b/doc/overview.rst
@@ -261,7 +261,6 @@ When run by ``PopenSpawn``, they may behave differently.
.. seealso::
- `winpexpect <https://pypi.python.org/pypi/winpexpect>`__ and
- `wexpect <https://gist.github.com/anthonyeden/8488763>`__
+ `winpexpect <https://pypi.python.org/pypi/winpexpect>`__ and `wexpect <https://gist.github.com/anthonyeden/8488763>`__
Two unmaintained pexpect-like modules for Windows, which work with a
hidden console.
diff --git a/pexpect/fdpexpect.py b/pexpect/fdpexpect.py
index e9a7664..cddd50e 100644
--- a/pexpect/fdpexpect.py
+++ b/pexpect/fdpexpect.py
@@ -138,7 +138,7 @@ class fdspawn(SpawnBase):
wlist = []
xlist = []
if self.use_poll:
- rlist = poll_ignore_interrupts(rlist[0], timeout)
+ rlist = poll_ignore_interrupts(rlist, timeout)
else:
rlist, wlist, xlist = select_ignore_interrupts(
rlist, wlist, xlist, timeout
diff --git a/pexpect/pty_spawn.py b/pexpect/pty_spawn.py
index bb36f7d..e0e2b54 100644
--- a/pexpect/pty_spawn.py
+++ b/pexpect/pty_spawn.py
@@ -447,7 +447,7 @@ class spawn(SpawnBase):
if not self.isalive():
# timeout of 0 means "poll"
if self.use_poll:
- r = poll_ignore_interrupts(self.child_fd, timeout)
+ r = poll_ignore_interrupts([self.child_fd], timeout)
else:
r, w, e = select_ignore_interrupts([self.child_fd], [], [], 0)
if not r:
@@ -458,14 +458,14 @@ class spawn(SpawnBase):
# FIXME So does this mean Irix systems are forced to always have
# FIXME a 2 second delay when calling read_nonblocking? That sucks.
if self.use_poll:
- r = poll_ignore_interrupts(self.child_fd, timeout)
+ r = poll_ignore_interrupts([self.child_fd], timeout)
else:
r, w, e = select_ignore_interrupts([self.child_fd], [], [], 2)
if not r and not self.isalive():
self.flag_eof = True
raise EOF('End Of File (EOF). Slow platform.')
if self.use_poll:
- r = poll_ignore_interrupts(self.child_fd, timeout)
+ r = poll_ignore_interrupts([self.child_fd], timeout)
else:
r, w, e = select_ignore_interrupts(
[self.child_fd], [], [], timeout
@@ -781,15 +781,16 @@ class spawn(SpawnBase):
return os.read(fd, 1000)
- def __interact_copy(self, escape_character=None,
- input_filter=None, output_filter=None):
+ def __interact_copy(
+ self, escape_character=None, input_filter=None, output_filter=None
+ ):
'''This is used by the interact() method.
'''
while self.isalive():
if self.use_poll:
- r = poll_ignore_interrupts(self.child_fd)
+ r = poll_ignore_interrupts([self.child_fd, self.STDIN_FILENO])
else:
r, w, e = select_ignore_interrupts(
[self.child_fd, self.STDIN_FILENO], [], []
diff --git a/pexpect/utils.py b/pexpect/utils.py
index 07a2d27..d901ae0 100644
--- a/pexpect/utils.py
+++ b/pexpect/utils.py
@@ -156,15 +156,17 @@ def select_ignore_interrupts(iwtd, owtd, ewtd, timeout=None):
raise
-def poll_ignore_interrupts(fd, timeout=None):
- '''Simple wrapper around poll to register a file descriptor and
+def poll_ignore_interrupts(fds, timeout=None):
+ '''Simple wrapper around poll to register file descriptors and
ignore signals.'''
if timeout is not None:
end_time = time.time() + timeout
poller = select.poll()
- poller.register(fd)
+ for fd in fds:
+ poller.register(fd)
+
while True:
try:
timeout_ms = None if timeout is None else timeout * 1000