@@ -147,7 +147,7 @@ def _connect_tunnel(self):
147147 'direct-tcpip' , (self .host , self .port ,), ('127.0.0.1' , 0 ))
148148 sleep (0 )
149149 return self ._connect (self .client , self .host , self .port , sock = proxy_channel )
150- except ChannelException , ex :
150+ except ChannelException as ex :
151151 error_type = ex .args [1 ] if len (ex .args ) > 1 else ex .args [0 ]
152152 raise ConnectionErrorException ("Error connecting to host '%s:%s' - %s" ,
153153 self .host , self .port ,
@@ -168,7 +168,7 @@ def _connect(self, client, host, port, sock=None, retries=1,
168168 port = port , pkey = pkey if pkey else self .pkey ,
169169 sock = sock , timeout = self .timeout ,
170170 allow_agent = self .allow_agent )
171- except sock_gaierror , ex :
171+ except sock_gaierror as ex :
172172 logger .error ("Could not resolve host '%s' - retry %s/%s" ,
173173 host , retries , self .num_retries )
174174 while retries < self .num_retries :
@@ -178,7 +178,7 @@ def _connect(self, client, host, port, sock=None, retries=1,
178178 raise UnknownHostException ("Unknown host %s - %s - retry %s/%s" ,
179179 host , str (ex .args [1 ]), retries ,
180180 self .num_retries )
181- except sock_error , ex :
181+ except sock_error as ex :
182182 logger .error ("Error connecting to host '%s:%s' - retry %s/%s" ,
183183 self .host , self .port , retries , self .num_retries )
184184 while retries < self .num_retries :
@@ -189,12 +189,12 @@ def _connect(self, client, host, port, sock=None, retries=1,
189189 raise ConnectionErrorException ("Error connecting to host '%s:%s' - %s - retry %s/%s" ,
190190 self .host , self .port ,
191191 str (error_type ), retries , self .num_retries ,)
192- except paramiko .AuthenticationException , ex :
192+ except paramiko .AuthenticationException as ex :
193193 msg = "Authentication error while connecting to %s:%s."
194194 raise AuthenticationException (msg , host , port )
195195 # SSHException is more general so should be below other types
196196 # of SSH failure
197- except paramiko .SSHException , ex :
197+ except paramiko .SSHException as ex :
198198 msg = "General SSH error - %s" % (ex ,)
199199 logger .error (msg )
200200 raise SSHException (msg , host , port )
@@ -289,7 +289,7 @@ def _mkdir(self, sftp, directory):
289289 """
290290 try :
291291 sftp .mkdir (directory )
292- except IOError , error :
292+ except IOError as error :
293293 msg = "Error occured creating directory %s on %s - %s"
294294 logger .error (msg , directory , self .host , error )
295295 raise IOError (msg , directory , self .host , error )
@@ -372,7 +372,7 @@ def copy_file(self, local_file, remote_file, recurse=False):
372372 sftp .chdir ()
373373 try :
374374 sftp .put (local_file , remote_file )
375- except Exception , error :
375+ except Exception as error :
376376 logger .error ("Error occured copying file %s to remote destination %s:%s - %s" ,
377377 local_file , self .host , remote_file , error )
378378 raise error
0 commit comments