@@ -845,18 +845,9 @@ def copy_file(self, local_file, remote_file, recurse=False):
845845
846846 def _copy_file (self , host , local_file , remote_file , recurse ):
847847 """Make sftp client, copy file"""
848- if not host in self .host_clients or not self .host_clients [host ]:
849- _user , _port , _password , _pkey = self ._get_host_config_values (host )
850- self .host_clients [host ] = SSHClient (
851- host , user = _user , password = _password , port = _port , pkey = _pkey ,
852- forward_ssh_agent = self .forward_ssh_agent ,
853- num_retries = self .num_retries ,
854- timeout = self .timeout ,
855- proxy_host = self .proxy_host ,
856- proxy_port = self .proxy_port ,
857- agent = self .agent ,
858- channel_timeout = self .channel_timeout )
859- return self .host_clients [host ].copy_file (local_file , remote_file , recurse = recurse )
848+ self ._make_ssh_client (host )
849+ return self .host_clients [host ].copy_file (local_file , remote_file ,
850+ recurse = recurse )
860851
861852 def copy_file_to_local (self , remote_file , local_file , recurse = False ):
862853 """Copy remote file to local file in parallel
@@ -883,9 +874,19 @@ def copy_file_to_local(self, remote_file, local_file, recurse=False):
883874
884875 def _copy_file_to_local (self , host , remote_file , local_file , recurse ):
885876 """Make sftp client, copy file to local"""
886- if not self .host_clients [host ]:
887- self .host_clients [host ] = SSHClient (host , user = self .user ,
888- password = self .password ,
889- port = self .port , pkey = self .pkey ,
890- forward_ssh_agent = self .forward_ssh_agent )
891- return self .host_clients [host ].copy_file_to_local (remote_file , '_' .join ([local_file , host ]), recurse = recurse )
877+ self ._make_ssh_client (host )
878+ return self .host_clients [host ].copy_file_to_local (
879+ remote_file , '_' .join ([local_file , host ]), recurse = recurse )
880+
881+ def _make_ssh_client (self , host ):
882+ if not host in self .host_clients or not self .host_clients [host ]:
883+ _user , _port , _password , _pkey = self ._get_host_config_values (host )
884+ self .host_clients [host ] = SSHClient (
885+ host , user = _user , password = _password , port = _port , pkey = _pkey ,
886+ forward_ssh_agent = self .forward_ssh_agent ,
887+ num_retries = self .num_retries ,
888+ timeout = self .timeout ,
889+ proxy_host = self .proxy_host ,
890+ proxy_port = self .proxy_port ,
891+ agent = self .agent ,
892+ channel_timeout = self .channel_timeout )
0 commit comments