diff options
author | Jeff Quast <contact@jeffquast.com> | 2015-04-24 21:18:27 -0700 |
---|---|---|
committer | Jeff Quast <contact@jeffquast.com> | 2015-04-24 21:18:27 -0700 |
commit | 5ded3108a0095ae6d94c3e25956ae6cd8ec33294 (patch) | |
tree | 132d2d37c84b5572160ad0898fb2a8570a4d6809 | |
parent | 05248aa57643d618bcd5e074bb159a309b0f1eb3 (diff) | |
parent | 8dafe9ad04bf3237b1c8a7c00e9c007b446ffc33 (diff) | |
download | pexpect-git-5ded3108a0095ae6d94c3e25956ae6cd8ec33294.tar.gz |
Merge remote-tracking branch 'origin/master' into bugfix-virtualenv
-rw-r--r-- | README.rst | 2 | ||||
-rw-r--r-- | doc/overview.rst | 6 | ||||
-rw-r--r-- | pexpect/async.py | 7 |
3 files changed, 8 insertions, 7 deletions
@@ -32,7 +32,7 @@ You can install Pexpect using pip:: `Docs on ReadTheDocs <http://pexpect.readthedocs.org/>`_ -PEXPECT LICENSE +PEXPECT LICENSE:: http://opensource.org/licenses/isc-license.txt diff --git a/doc/overview.rst b/doc/overview.rst index a04e389..76fc846 100644 --- a/doc/overview.rst +++ b/doc/overview.rst @@ -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) diff --git a/pexpect/async.py b/pexpect/async.py index 50eae3b..99a0b28 100644 --- a/pexpect/async.py +++ b/pexpect/async.py @@ -6,10 +6,11 @@ from pexpect import EOF @asyncio.coroutine def expect_async(expecter, timeout=None): # First process data that was previously read - if it maches, we don't need - # async stuff. - idx = expecter.new_data(expecter.spawn.buffer) + # async stuff. + previously_read = expecter.spawn.buffer expecter.spawn.buffer = expecter.spawn.string_type() - if idx: + idx = expecter.new_data(previously_read) + if idx is not None: return idx transport, pw = yield from asyncio.get_event_loop()\ |