From 3700d6e151d7891a12b958cf8f2729576205d927 Mon Sep 17 00:00:00 2001 From: Ken Jordan Date: Thu, 22 Jan 2015 19:39:22 -0700 Subject: Updated agent.py to print a more appropriate exception when unable to connect to the SSH agent --- paramiko/agent.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/paramiko/agent.py b/paramiko/agent.py index a75ac59e..185666e7 100644 --- a/paramiko/agent.py +++ b/paramiko/agent.py @@ -32,7 +32,7 @@ from select import select from paramiko.common import asbytes, io_sleep from paramiko.py3compat import byte_chr -from paramiko.ssh_exception import SSHException +from paramiko.ssh_exception import SSHException, AuthenticationException from paramiko.message import Message from paramiko.pkey import PKey from paramiko.util import retry_on_signal @@ -109,9 +109,15 @@ class AgentProxyThread(threading.Thread): def run(self): try: (r, addr) = self.get_connection() + # Found that r should be either a socket from the socket library or None self.__inr = r - self.__addr = addr + self.__addr = addr # This should be an IP address as a string? or None self._agent.connect() + print("Conn Value: ", self._agent._conn) + print("Has fileno method: ", hasattr(self._agent._conn, 'fileno')) + print("Verify isinstance of int: ", isinstance(self._agent, int)) + if self._agent._conn is None or not (hasattr(self._agent._conn, 'fileno') or isinstance(self._agent, int)): + raise AuthenticationException("Unable to connect to SSH agent") self._communicate() except: #XXX Not sure what to do here ... raise or pass ? -- cgit v1.2.3