fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] rsync_project


From: Niklas Lindström
Subject: Re: [Fab-user] rsync_project
Date: Wed, 25 Mar 2009 14:20:15 +0100

It sounds quite usable. I'd prefer if it could take an argument to the
"project" directory though, to facilitate rsyncing of different parts
using the same fabric setup.

(Currently, I have fabfile(s) in a separate directory, which I use to
deploy stuff from several java-maven-modules, a resource dir etc.)

Best regards,
Niklas


On Wed, Mar 25, 2009 at 11:38 AM, Christian Vest Hansen
<address@hidden> wrote:
> I think it is useful under the premise that upload_project is useful.
>
> I can't really decide wether it was a good idea or not to add in
> upload_project in the first place, but that's how it happened. Ideally
> there should be a better place for these more perifiral functions, but
> not such place exists in the current code base.
>
> Given that, it is a change that I am tempted to apply.
>
> On Sat, Mar 21, 2009 at 11:51 PM, Paul Baumgart <address@hidden> wrote:
>> A different topic this time:
>>
>> The current upload_project() function is a neat feature, but I have
>> two issues with it:
>>
>> 1) It doesn't allow me to exclude certain files/directories (like
>> .git* for example)
>> 2) It uploads the entire project every time, which can be irritating
>> if the change is small but the project is large.
>>
>> So, I made this function, which uses rsync to only upload the
>> differences between the local and remote copies.
>>
>> I would like to get feedback on it, primarily as to whether this would
>> be useful in the mainline Fabric code, and if not, if there is any way
>> to make it be useful.
>>
>> @operation
>> @connects
>> def rsync_project(host, client, env, remotepath, exclude=False,
>> delete=False, extra_opts='', **kwargs):
>>    """
>>    Uploads the current project directory using rsync, so only changes are
>>    uploaded rather than the whole directory like using upload_project.
>>
>>    Requires the rsync command-line utility to be available both on the local
>>    and the remote machine.
>>
>>    Parameters are:
>>        remotepath:         the path on the remote machine to which to rsync 
>> the
>>                            current project
>>        exclude (optional): the string passed to rsync's --exclude option.
>>                            See the rsync manpage for details.
>>        delete (optional):  True or False, whether to delete remote files that
>>                            don't exist locally.
>>        extra_opts (optional): Additional command-line options to set for 
>> rsync.
>>
>>    The rsync command is built from the options as follows:
>>        rsync [--delete] [--exclude exclude] -pthrvz [extra_opts]
>> <project dir> <fab_user>@<host>:<remotepath>
>>    """
>>
>>    remotepath = _lazy_format(remotepath, env)
>>
>>    username = ENV.get('fab_user')
>>    username = username + '@' if username else username
>>
>>    cwd_name = '../' + os.getcwd().split(os.sep)[-1]
>>
>>    delete_opt = '--delete' if delete else ''
>>
>>    exclude_opt = '--exclude' if exclude else ''
>>    exclude = '"' + exclude.strip('"') + '"' if exclude else ''
>>
>>    return local('rsync %(delete_opt)s %(exclude_opt)s %(exclude)s
>> -pthrvz %(extra_opts)s %(cwd_name)s
>> %(username)s%(host)s:%(remotepath)s'
>>        % locals(), **kwargs) == 0
>>
>>
>> Note that it requires adding a line to the bottom of local():
>>
>> return retcode
>>
>> Regards,
>> Paul
>>
>>
>> _______________________________________________
>> Fab-user mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/fab-user
>>
>
>
>
> --
> Venlig hilsen / Kind regards,
> Christian Vest Hansen.
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]