Hi Paul,

I have a function that uses `local` for localhost, and `run` otherwise. See
https://gist.github.com/JensRantil/655b7f9ecd5af933f792 Not sure it solves
your problem, but maybe could inspire you?

Cheers,
Jens


On Sun, Nov 10, 2013 at 4:16 PM, Paul Walsh <paulywa...@gmail.com> wrote:

> Hi all,
>
> I've been using Fabric for some time, and just learning what I need to
> know as I need to know it.
>
> However, in the last months, I've started packaging up my commonly used
> tasks so I can just include the package in my various projects, and not
> copy/paste my fabfiles.
>
> In packaging my code, I looked for ways to make things more generic, and
> the one thing I find annoying in this endeavour is the distinction between
> `local` on one hand, and `run` & `sudo` on the other. I have quite a bit of
> code that I end up writing twice - one task to wrap calls in local, and
> another one exactly the same, but using run and/or sudo.
>
> I am wondering if there are any best practices for dealing with this.
>
> A simple example:
>
> #fabfile/local.py
> @task
> def db_drop():
>     local('code to drop the db')
>
> #fabfile/remote.py
> @task
> db_drop():
>     run('code to drop the db')
>
>
>
> _______________________________________________
> Fab-user mailing list
> Fab-user@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/fab-user
>
_______________________________________________
Fab-user mailing list
Fab-user@nongnu.org
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to