Paul Walsh
2013-11-10 15:16:16 UTC
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')
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')