'A better copy command that works with files or directories.
Respects the ``MULTIPLE_APP_SERVERS`` setting when copying.'

@classmethod
def copy(cls, path, target, is_file=False, **__):

    sync_user = getattr(settings, 'SYNC_USER', getpass.getuser())
    app_servers = getattr(settings, 'MULTIPLE_APP_SERVERS', [])
    if app_servers:
        log.info('Remote    Copy    %s    to    %s    on    %s', path, target, app_servers)
        for server in app_servers:
            mkdir_cmd = ('ssh    %s@%s    mkdir    -p    %s' % (sync_user, server, target))
            ret = os.system(mkdir_cmd)
            if (ret != 0):
                log.info('COPY    ERROR    to    app    servers:')
                log.info(mkdir_cmd)
            if is_file:
                slash = ''
            else:
                slash = '/'
            sync_cmd = "rsync    -e    'ssh    -T'    -av    --delete    {path}{slash}    {user}@{server}:{target}".format(path=path, slash=slash, user=sync_user, server=server, target=target)
            ret = os.system(sync_cmd)
            if (ret != 0):
                log.info('COPY    ERROR    to    app    servers.')
                log.info(sync_cmd)
