The login call fails when the remote system responds with a short login message that contains none of the symbols in the default prompt. For example, this login session will fail:
Last login: Wed Sep 10 12:46:03 2008 from h-67-101-212-195.snfccasy.dynamic.covad.net
[jeff@mother ~]$
The cause is line 134 of pxssh.py:
self.read_nonblocking(size=10000,timeout=1) # GAS: Clear out the cache before getting the prompt
This is the first line of the function. It turns out that surprising number of default login messages contain one $ or one #. This initial read copes wonderfully with that. Unfortunately when they don't, the expect channel will be empty, and this line will raise a TIMEOUT.
My suggested fix involves catching the timeout, replacing the offending line with:
# JMY 9/10/2008:
# It turns out that the first read_nonblocking is necessary
# because many MOTDs have the expected default prompt embedded.
# If the system MOTD doesn't match [$#] and the system
# responds very quickly then there will be no more data to
# read, and the line added by GAS will cause a TIMEOUT.
#
# I've addressed this by catching the TIMEOUT. It works,
# but I'm not sure it's the correct solution.
try:
self.read_nonblocking(size=10000,timeout=1) # GAS: Clear out the cache before getting the prompt
except TIMEOUT:
pass