'Copy files from a local path to the remote host.
Directories will be copied recursively.
If a source component is a directory with a trailing slash,
the content of the directory will be copied, otherwise, the
directory itself and its content will be copied. This
behavior is similar to that of the program \'rsync\'.
Args:
source: either
1) a single file or directory, as a string
2) a list of one or more (possibly mixed)
files or directories
dest: a file or a directory (if source contains a
directory or more than one element, you must
supply a directory dest)
delete_dest: if this is true, the command will also clear
out any old files at dest that are not in the
source
preserve_symlinks: controls if symlinks on the source will be
copied as such on the destination or transformed into the
referenced file/directory
Raises:
AutoservRunError: the scp command failed'

def send_file(self, source, dest, delete_dest=False, preserve_symlinks=False):

    self.start_master_ssh()
    if isinstance(source, basestring):
        source_is_dir = os.path.isdir(source)
        source = [source]
    remote_dest = self._encode_remote_paths([dest])
    try_scp = True
    if self.use_rsync():
        try:
            local_sources = [utils.sh_escape(path) for path in source]
            rsync = self._make_rsync_cmd(local_sources, remote_dest, delete_dest, preserve_symlinks)
            utils.run(rsync)
            try_scp = False
        except error.CmdError as e:
            logging.warn(('trying    scp,    rsync    failed:    %s' % e))
    if try_scp:
        if delete_dest:
            dest_exists = False
            try:
                self.run(('test    -x    %s' % dest))
                dest_exists = True
            except error.AutoservRunError:
                pass
            dest_is_dir = False
            if dest_exists:
                try:
                    self.run(('test    -d    %s' % dest))
                    dest_is_dir = True
                except error.AutoservRunError:
                    pass
            if ((len(source) > 1) or source_is_dir):
                dest_is_dir = True
            if (dest_exists and dest_is_dir):
                cmd = ('rm    -rf    %s    &&    mkdir    %s' % (dest, dest))
                self.run(cmd)
            elif ((not dest_exists) and dest_is_dir):
                cmd = ('mkdir    %s' % dest)
                self.run(cmd)
        local_sources = self._make_rsync_compatible_source(source, True)
        if local_sources:
            scp = self._make_scp_cmd(local_sources, remote_dest)
            try:
                utils.run(scp)
            except error.CmdError as e:
                raise error.AutoservRunError(e.args[0], e.args[1])
