diff options
author | noah <noah@656d521f-e311-0410-88e0-e7920216d269> | 2008-02-09 18:05:33 +0000 |
---|---|---|
committer | noah <noah@656d521f-e311-0410-88e0-e7920216d269> | 2008-02-09 18:05:33 +0000 |
commit | e6bcb3515d3cc8fa79b2f8a620c7ef2a59cd91d9 (patch) | |
tree | f5a48c8d7434182c9adda8f01c3dbdac531f9320 | |
parent | beeea12adc0f411499211c356898f7fed65b8415 (diff) | |
download | pexpect-e6bcb3515d3cc8fa79b2f8a620c7ef2a59cd91d9.tar.gz |
Added patch by John Spiegel john at jspiegel.net.
> It seems the sync_original_prompt() function in pxssh expects to flush the
> input with a read_nonblocking(), but when there's nothing to read,
> read_nonblocking() throws, preventing me from logging in. This fixed it for
> me:
>
> Only in pexpect-2.3.new/: build
> diff -r pexpect-2.3/pxssh.py pexpect-2.3.new/pxssh.py
> 134c134,137
> < self.read_nonblocking(size=10000,timeout=1) # GAS: Clear out the cache before getting the prompt
> ---
> > try:
> > self.read_nonblocking(size=10000,timeout=1) # GAS: Clear out the cache before getting the prompt
> > except TIMEOUT:
> > pass
>
> Hope that's helpful,
> John
>
git-svn-id: http://pexpect.svn.sourceforge.net/svnroot/pexpect/trunk@512 656d521f-e311-0410-88e0-e7920216d269
-rw-r--r-- | pexpect/pexpect.py | 3 | ||||
-rw-r--r-- | pexpect/pxssh.py | 8 |
2 files changed, 8 insertions, 3 deletions
diff --git a/pexpect/pexpect.py b/pexpect/pexpect.py index b1fb989..4d3fdc6 100644 --- a/pexpect/pexpect.py +++ b/pexpect/pexpect.py @@ -35,7 +35,8 @@ Robert Stone, Hartmut Goebel, Chad Schroeder, Erick Tryzelaar, Dave Kirby, Ids vander Molen, George Todd, Noel Taylor, Nicolas D. Cesar, Alexander Gattin, Geoffrey Marshall, Francisco Lourenco, Glen Mabey, Karthik Gurusamy, Fernando Perez, Corey Minyard, Jon Cohen, Guillaume Chazarain, Andrew Ryan, Nick -Craig-Wood, Andrew Stone, Jorgen Grahn (Let me know if I forgot anyone.) +Craig-Wood, Andrew Stone, Jorgen Grahn, John Spiegel (Let me know if I forgot +anyone.) Free, open source, and all that good stuff. diff --git a/pexpect/pxssh.py b/pexpect/pxssh.py index 708b967..fd861ed 100644 --- a/pexpect/pxssh.py +++ b/pexpect/pxssh.py @@ -124,14 +124,18 @@ class pxssh (spawn): """This attempts to find the prompt. Basically, press enter and record the response; press enter again and record the response; if the two - responses are similar then assume we are at the original prompt. """ + responses are similar then assume we are at the original prompt. This + is a slow function. It can take over 10 seconds. """ # All of these timing pace values are magic. # I came up with these based on what seemed reliable for # connecting to a heavily loaded machine I have. # If latency is worse than these values then this will fail. - self.read_nonblocking(size=10000,timeout=1) # GAS: Clear out the cache before getting the prompt + try: + self.read_nonblocking(size=10000,timeout=1) # GAS: Clear out the cache before getting the prompt + except TIMEOUT: + pass time.sleep(0.1) self.sendline() time.sleep(0.5) |