diff options
author | dluyer <53582923+dluyer@users.noreply.github.com> | 2020-01-09 14:32:41 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-09 14:32:41 -0800 |
commit | bad8a63c7df1d5033cb108ba370b182225d6f84f (patch) | |
tree | b7f4a4bf36715a45a0b8d2a24a0c13619dfebda7 | |
parent | e62022859afaa1d5e435d75fe4ea5491c1323dd9 (diff) | |
parent | 7db2929598d15cfb664dd910fe5329929de4ef95 (diff) | |
download | pexpect-git-bad8a63c7df1d5033cb108ba370b182225d6f84f.tar.gz |
Merge pull request #5 from dluyer/master
Merge from master
-rw-r--r-- | doc/examples.rst | 2 | ||||
-rwxr-xr-x | examples/astat.py | 2 | ||||
-rwxr-xr-x | examples/chess.py | 2 | ||||
-rwxr-xr-x | examples/chess2.py | 2 | ||||
-rwxr-xr-x | examples/chess3.py | 2 | ||||
-rwxr-xr-x | examples/hive.py | 4 | ||||
-rwxr-xr-x | examples/topip.py | 2 | ||||
-rw-r--r-- | pexpect/expect.py | 10 | ||||
-rw-r--r-- | pexpect/pty_spawn.py | 7 |
9 files changed, 20 insertions, 13 deletions
diff --git a/doc/examples.rst b/doc/examples.rst index 6338b5c..be48f6a 100644 --- a/doc/examples.rst +++ b/doc/examples.rst @@ -48,7 +48,7 @@ Examples. `python.py <https://github.com/pexpect/pexpect/blob/master/examples/python.py>`_ This starts the python interpreter and prints the greeting message - backwards. It then gives the user iteractive control of Python. It's + backwards. It then gives the user interactive control of Python. It's pretty useless! `ssh_tunnel.py <https://github.com/pexpect/pexpect/blob/master/examples/ssh_tunnel.py>`_ diff --git a/examples/astat.py b/examples/astat.py index abba1be..50937a3 100755 --- a/examples/astat.py +++ b/examples/astat.py @@ -38,7 +38,7 @@ import os import sys import getopt import getpass -import pxssh +from pexpect import pxssh try: diff --git a/examples/chess.py b/examples/chess.py index f97a3a9..a15fd94 100755 --- a/examples/chess.py +++ b/examples/chess.py @@ -27,7 +27,7 @@ from __future__ import print_function from __future__ import absolute_import import pexpect -import ANSI +from pexpect import ANSI REGEX_MOVE = r'(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)' REGEX_MOVE_PART = r'(?:[0-9]|\x1b\[C)(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)' diff --git a/examples/chess2.py b/examples/chess2.py index b92509e..f8a7c24 100755 --- a/examples/chess2.py +++ b/examples/chess2.py @@ -27,7 +27,7 @@ from __future__ import print_function from __future__ import absolute_import import pexpect -import ANSI +from pexpect import ANSI import sys import time diff --git a/examples/chess3.py b/examples/chess3.py index 2c087b0..e3e6200 100755 --- a/examples/chess3.py +++ b/examples/chess3.py @@ -27,7 +27,7 @@ from __future__ import print_function from __future__ import absolute_import import pexpect -import ANSI +from pexpect import ANSI REGEX_MOVE = r'(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)' REGEX_MOVE_PART = r'(?:[0-9]|\x1b\[C)(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)' diff --git a/examples/hive.py b/examples/hive.py index 1b7bcbf..0d34b03 100755 --- a/examples/hive.py +++ b/examples/hive.py @@ -94,7 +94,7 @@ import readline import atexit try: import pexpect - import pxssh + from pexpect import pxssh except ImportError: sys.stderr.write("You do not have 'pexpect' installed.\n") sys.stderr.write("On Ubuntu you need the 'python-pexpect' package.\n") @@ -436,7 +436,7 @@ def resync (hive, hive_names, timeout=2, max_attempts=5): def parse_host_connect_string (hcs): '''This parses a host connection string in the form - username:password@hostname:port. All fields are options expcet hostname. A + username:password@hostname:port. All fields are optional except hostname. A dictionary is returned with all four keys. Keys that were not included are set to empty strings ''. Note that if your password has the '@' character then you must backslash escape it. ''' diff --git a/examples/topip.py b/examples/topip.py index 64dac30..9cf3824 100755 --- a/examples/topip.py +++ b/examples/topip.py @@ -70,7 +70,7 @@ from __future__ import unicode_literals # See http://pexpect.sourceforge.net/ import pexpect -import pxssh +from pexpect import pxssh import os import sys import time diff --git a/pexpect/expect.py b/pexpect/expect.py index a9c3c49..d6600a9 100644 --- a/pexpect/expect.py +++ b/pexpect/expect.py @@ -110,7 +110,10 @@ class Expecter(object): msg += '\nsearcher: %s' % self.searcher if err is not None: msg = str(err) + '\n' + msg - raise EOF(msg) + + exc = EOF(msg) + exc.__cause__ = None # in Python 3.x we can use "raise exc from None" + raise exc def timeout(self, err=None): spawn = self.spawn @@ -129,7 +132,10 @@ class Expecter(object): msg += '\nsearcher: %s' % self.searcher if err is not None: msg = str(err) + '\n' + msg - raise TIMEOUT(msg) + + exc = TIMEOUT(msg) + exc.__cause__ = None # in Python 3.x we can use "raise exc from None" + raise exc def errored(self): spawn = self.spawn diff --git a/pexpect/pty_spawn.py b/pexpect/pty_spawn.py index 58d57f7..8e28ca7 100644 --- a/pexpect/pty_spawn.py +++ b/pexpect/pty_spawn.py @@ -191,6 +191,7 @@ class spawn(SpawnBase): self.STDIN_FILENO = pty.STDIN_FILENO self.STDOUT_FILENO = pty.STDOUT_FILENO self.STDERR_FILENO = pty.STDERR_FILENO + self.str_last_chars = 100 self.cwd = cwd self.env = env self.echo = echo @@ -212,8 +213,8 @@ class spawn(SpawnBase): s.append(repr(self)) s.append('command: ' + str(self.command)) s.append('args: %r' % (self.args,)) - s.append('buffer (last 100 chars): %r' % self.buffer[-100:]) - s.append('before (last 100 chars): %r' % self.before[-100:] if self.before else '') + s.append('buffer (last %s chars): %r' % (self.str_last_chars,self.buffer[-self.str_last_chars:])) + s.append('before (last %s chars): %r' % (self.str_last_chars,self.before[-self.str_last_chars:] if self.before else '')) s.append('after: %r' % (self.after,)) s.append('match: %r' % (self.match,)) s.append('match_index: ' + str(self.match_index)) @@ -779,7 +780,7 @@ class spawn(SpawnBase): signal.signal(signal.SIGWINCH, sigwinch_passthrough) p.interact() ''' - + # Flush the buffer. self.write_to_stdout(self.buffer) self.stdout.flush() |