summaryrefslogtreecommitdiff
path: root/pexpect/pxssh.py
diff options
context:
space:
mode:
authornoah <noah@656d521f-e311-0410-88e0-e7920216d269>2008-02-09 18:05:33 +0000
committernoah <noah@656d521f-e311-0410-88e0-e7920216d269>2008-02-09 18:05:33 +0000
commitae0179a783e1bf5fe37392c4ca38ff5dacaec52e (patch)
treef5a48c8d7434182c9adda8f01c3dbdac531f9320 /pexpect/pxssh.py
parent3e976cbba0f4f89e97fd9af8901a66b8881c4072 (diff)
downloadpexpect-ae0179a783e1bf5fe37392c4ca38ff5dacaec52e.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 >
Diffstat (limited to 'pexpect/pxssh.py')
-rw-r--r--pexpect/pxssh.py8
1 files changed, 6 insertions, 2 deletions
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)