oops. fix potential exception when there's no ssh agent available.

This commit is contained in:
Robey Pointer 2011-05-23 13:40:33 -07:00
parent 18f6a836da
commit afae8dd7c5
1 changed files with 3 additions and 1 deletions

View File

@ -55,6 +55,7 @@ class Agent:
@raise SSHException: if an SSH agent is found, but speaks an @raise SSHException: if an SSH agent is found, but speaks an
incompatible protocol incompatible protocol
""" """
self.conn = None
self.keys = () self.keys = ()
if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'): if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'):
conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@ -87,7 +88,8 @@ class Agent:
""" """
Close the SSH agent connection. Close the SSH agent connection.
""" """
self.conn.close() if self.conn is not None:
self.conn.close()
self.conn = None self.conn = None
self.keys = () self.keys = ()