From 547c1f9c865cc39504171677e530add8eb1fcf07 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 8 Jan 2014 23:53:08 +0100 Subject: [PATCH] copy files instead of directories to give --remote-copy implementation a chance to dereference symlinks also fixes #242 by filtering 'hidden' files (starting with a dot) Signed-off-by: Steven Armstrong --- cdist/exec/remote.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cdist/exec/remote.py b/cdist/exec/remote.py index 2c42201a..7c807092 100644 --- a/cdist/exec/remote.py +++ b/cdist/exec/remote.py @@ -23,6 +23,7 @@ import io import os import sys +import glob import subprocess import logging @@ -94,9 +95,17 @@ class Remote(object): """Transfer a file or directory to the remote side.""" self.log.debug("Remote transfer: %s -> %s", source, destination) self.rmdir(destination) - command = self._copy.split() - command.extend(["-r", source, self.target_host + ":" + destination]) - self._run_command(command) + if os.path.isdir(source): + self.mkdir(destination) + for f in glob.glob1(source, '*'): + command = self._copy.split() + path = os.path.join(source, f) + command.extend([path, '{0}:{1}'.format(self.target_host, destination)]) + self._run_command(command) + else: + command = self._copy.split() + command.extend([source, '{0}:{1}'.format(self.target_host, destination)]) + self._run_command(command) def run_script(self, script, env=None, return_output=False): """Run the given script with the given environment on the remote side.