summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordluyer <53582923+dluyer@users.noreply.github.com>2020-01-09 14:31:11 -0800
committerGitHub <noreply@github.com>2020-01-09 14:31:11 -0800
commit7db2929598d15cfb664dd910fe5329929de4ef95 (patch)
treeec0bfd53f8e985899f78707caeb2525b201efcf4
parente99f21c595af125a72d8fbb5bc562917ba24eff9 (diff)
parent692681f719ecca280c77e3a04c24ef8be64696a4 (diff)
downloadpexpect-git-7db2929598d15cfb664dd910fe5329929de4ef95.tar.gz
Merge pull request #4 from pexpect/master
Merge updates from master
-rw-r--r--doc/examples.rst2
-rwxr-xr-xexamples/astat.py2
-rwxr-xr-xexamples/chess.py2
-rwxr-xr-xexamples/chess2.py2
-rwxr-xr-xexamples/chess3.py2
-rwxr-xr-xexamples/hive.py4
-rwxr-xr-xexamples/topip.py2
-rw-r--r--pexpect/expect.py10
-rw-r--r--pexpect/pty_spawn.py7
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 db376d5..34a2c93 100644
--- a/pexpect/expect.py
+++ b/pexpect/expect.py
@@ -60,7 +60,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
@@ -79,7 +82,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()