[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] rsync_project
From: |
Christian Vest Hansen |
Subject: |
Re: [Fab-user] rsync_project |
Date: |
Thu, 2 Apr 2009 21:17:57 +0200 |
On Sun, Mar 22, 2009 at 12:51 AM, 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]
This line right here. Why do you go through all this trouble to build
a relative CWD?
>
> 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.
- Re: [Fab-user] rsync_project,
Christian Vest Hansen <=
- Re: [Fab-user] rsync_project, Christian Vest Hansen, 2009/04/02
- Re: [Fab-user] rsync_project, Paul Baumgart, 2009/04/02
- Re: [Fab-user] rsync_project, Christian Vest Hansen, 2009/04/03
- Re: [Fab-user] rsync_project, Paul Baumgart, 2009/04/03
- Re: [Fab-user] rsync_project, Christian Vest Hansen, 2009/04/03
- Re: [Fab-user] rsync_project, Paul Baumgart, 2009/04/03
- Re: [Fab-user] rsync_project, Christian Vest Hansen, 2009/04/03