@@ -139,8 +139,8 @@ def __init__(self, host,
139139 self .proxy_command = paramiko .ProxyCommand (host_config ['proxycommand' ]) if 'proxycommand' in \
140140 host_config else None
141141 if self .proxy_command :
142- logger .debug ("Proxy configured for destination host %s - ProxyCommand: '%s'" % (
143- self .host , " " .join (self .proxy_command .cmd ),) )
142+ logger .debug ("Proxy configured for destination host %s - ProxyCommand: '%s'" ,
143+ self .host , " " .join (self .proxy_command .cmd ),)
144144 if _agent :
145145 self .client ._agent = _agent
146146 self ._connect ()
@@ -153,26 +153,26 @@ def _connect(self, retries=1):
153153 pkey = self .pkey ,
154154 sock = self .proxy_command )
155155 except socket .gaierror , e :
156- logger .error ("Could not resolve host '%s'" , self .host ,)
156+ logger .error ("Could not resolve host '%s' - retry %s/%s" ,
157+ self .host , retries , NUM_RETRIES )
157158 while retries < NUM_RETRIES :
158159 gevent .sleep (5 )
159160 return self ._connect (retries = retries + 1 )
160161 raise UnknownHostException ("%s - %s" % (str (e .args [1 ]),
161162 self .host ,))
162163 except socket .error , e :
163- logger .error ("Error connecting to host '%s:%s'" % ( self . host ,
164- self .port ,) )
164+ logger .error ("Error connecting to host '%s:%s' - retry %s/%s" ,
165+ self . host , self .port , retries , NUM_RETRIES )
165166 while retries < NUM_RETRIES :
166167 gevent .sleep (5 )
167168 return self ._connect (retries = retries + 1 )
168- raise ConnectionErrorException ("%s for host '%s:%s'" % ( str ( e . args [ 1 ]) ,
169- self .host ,
170- self . port ,) )
169+ raise ConnectionErrorException ("%s for host '%s:%s' - retry %s/%s" ,
170+ str ( e . args [ 1 ]), self .host , self . port ,
171+ retries , NUM_RETRIES , )
171172 except paramiko .AuthenticationException , e :
172173 raise AuthenticationException (e )
173174 except paramiko .ProxyCommandFailure , e :
174- logger .error ("Error executing ProxyCommand - %s" % (
175- e .message ,))
175+ logger .error ("Error executing ProxyCommand - %s" , e .message ,)
176176 raise ProxyCommandException (e .message )
177177
178178 def exec_command (self , command , sudo = False , ** kwargs ):
@@ -188,7 +188,7 @@ def exec_command(self, command, sudo=False, **kwargs):
188188 :type sudo: bool
189189 :param kwargs: (Optional) Keyword arguments to be passed to remote \
190190 command
191- :type kwargs: dict
191+ :type kwargs: dict
192192 :rtype: Tuple of `(channel, hostname, stdout, stderr)`. \
193193 Channel is the remote SSH channel, needed to ensure all of stdout has \
194194 been got, hostname is remote hostname the copy is to, stdout and \
@@ -215,7 +215,7 @@ def exec_command(self, command, sudo=False, **kwargs):
215215 def _make_sftp (self ):
216216 """Make SFTP client from open transport"""
217217 transport = self .client .get_transport ()
218- channel = transport .open_session ()
218+ transport .open_session ()
219219 return paramiko .SFTPClient .from_transport (transport )
220220
221221 def mkdir (self , sftp , directory ):
@@ -246,7 +246,6 @@ def copy_file(self, local_file, remote_file):
246246 """
247247 sftp = self ._make_sftp ()
248248 destination = remote_file .split (os .path .sep )
249- filename = destination [0 ] if len (destination ) == 1 else destination [- 1 ]
250249 remote_file = os .path .sep .join (destination )
251250 destination = destination [:- 1 ]
252251 for directory in destination :
0 commit comments