fabric API direct call in python

whi picture whi · Aug 8, 2012 · Viewed 9.8k times · Source

i remember fabric API can be called directly in py script but forgot where to start anybody give a clue?

Answer

Fedor Gogolev picture Fedor Gogolev · Aug 8, 2012

Yes, you can call it, for example:

from fabric.api import run
from fabric.tasks import execute


def do_something():
    run("echo $RANDOM")

if __name__ == "__main__":
    execute(do_something, hosts=["username@host"])