@@ -85,13 +85,22 @@ def from_str(cls, method_str):
85
85
raise ValueError ("Invalid or unsupported method '%s' given" % method_str )
86
86
87
87
88
- def _get_put_method_args (method , host , src , dst ):
88
+ def _get_put_method_args (method , host , src , dst , config ):
89
89
port_args = []
90
+
91
+ config_args = []
92
+ if config :
93
+ config_args += ["-F" , config ]
94
+
90
95
if method == PutMethod .SCP :
91
96
if host .port != _DEFAULT_SSH_PORT :
92
97
port_args += ["-P" , str (host .port )]
93
98
return (
94
- ["scp" , "-r" ] + DEFAULT_SSH_ARGS + port_args + [src , host .login + ":" + dst ]
99
+ ["scp" , "-r" ]
100
+ + config_args
101
+ + DEFAULT_SSH_ARGS
102
+ + port_args
103
+ + [src , host .login + ":" + dst ]
95
104
)
96
105
elif method == PutMethod .RSYNC :
97
106
if host .port != _DEFAULT_SSH_PORT :
@@ -100,7 +109,10 @@ def _get_put_method_args(method, host, src, dst):
100
109
"rsync" ,
101
110
"-a" ,
102
111
"-e" ,
103
- "ssh " + " " .join (DEFAULT_SSH_ARGS + port_args + host .extra_ssh_args ),
112
+ "ssh "
113
+ + " " .join (
114
+ config_args + DEFAULT_SSH_ARGS + port_args + host .extra_ssh_args
115
+ ),
104
116
] + [src , host .login + ":" + dst ]
105
117
else :
106
118
raise ValueError ("Invalid or unsupported method '%s' given" % method )
@@ -302,6 +314,7 @@ def execute(
302
314
ignore_failed = False ,
303
315
echo = True ,
304
316
echo_cmd = False ,
317
+ config = None ,
305
318
): # TODO: parallel=False
306
319
"""Execute command on remote hosts (in parallel)
307
320
@@ -337,8 +350,12 @@ def execute(
337
350
port_args = []
338
351
if host .port != _DEFAULT_SSH_PORT :
339
352
port_args += ["-p" , str (host .port )]
353
+ config_args = []
354
+ if config :
355
+ config_args += ["-F" , config ]
340
356
proc = subprocess .Popen (
341
357
["ssh" , host .login ]
358
+ + config_args
342
359
+ DEFAULT_SSH_ARGS
343
360
+ port_args
344
361
+ host .extra_ssh_args
@@ -362,6 +379,7 @@ def execute_commands(
362
379
ignore_failed = False ,
363
380
echo = True ,
364
381
echo_cmd = True ,
382
+ config = None ,
365
383
): # TODO: parallel=False
366
384
"""A more flexible version of the :func:`execute` function
367
385
@@ -393,8 +411,12 @@ def execute_commands(
393
411
port_args = []
394
412
if host .port != _DEFAULT_SSH_PORT :
395
413
port_args += ["-p" , str (host .port )]
414
+ config_args = []
415
+ if not config :
416
+ config_args += ["-F" , config ]
396
417
proc = subprocess .Popen (
397
418
["ssh" , host .login ]
419
+ + config_args
398
420
+ DEFAULT_SSH_ARGS
399
421
+ port_args
400
422
+ host .extra_ssh_args
@@ -411,7 +433,13 @@ def execute_commands(
411
433
412
434
413
435
def put (
414
- hosts , src , dst = None , method = PutMethod .SCP , ignore_failed = False , echo = True
436
+ hosts ,
437
+ src ,
438
+ dst = None ,
439
+ method = PutMethod .SCP ,
440
+ ignore_failed = False ,
441
+ echo = True ,
442
+ config = None ,
415
443
): # TODO: parallel=False
416
444
"""Copy files to remote hosts
417
445
@@ -451,7 +479,7 @@ def put(
451
479
hosts = _hosts_to_host_specs (hosts )
452
480
for host in hosts :
453
481
proc = subprocess .Popen (
454
- _get_put_method_args (method , host , src , dst ),
482
+ _get_put_method_args (method , host , src , dst , config ),
455
483
stdout = subprocess .PIPE ,
456
484
stderr = subprocess .PIPE ,
457
485
universal_newlines = True ,
@@ -464,7 +492,13 @@ def put(
464
492
465
493
466
494
def put_to_hosts (
467
- hosts , data , get_src_dst_fn , method = PutMethod .SCP , ignore_failed = False , echo = True
495
+ hosts ,
496
+ data ,
497
+ get_src_dst_fn ,
498
+ method = PutMethod .SCP ,
499
+ ignore_failed = False ,
500
+ echo = True ,
501
+ config = None ,
468
502
):
469
503
"""A more flexible version of the :func:`put` function
470
504
@@ -490,7 +524,7 @@ def put_to_hosts(
490
524
src , dst = src_dst
491
525
dst = dst or src # `dst` defaults to `src`
492
526
proc = subprocess .Popen (
493
- _get_put_method_args (method , host , src , dst ),
527
+ _get_put_method_args (method , host , src , dst , config ),
494
528
stdout = subprocess .PIPE ,
495
529
stderr = subprocess .PIPE ,
496
530
universal_newlines = True ,
0 commit comments