PROJET AUTOBLOG


Sam et Max

source: Sam et Max

⇐ retour index

Appeler une fonction fabric, hors d’un fichier fabfile

dimanche 14 avril 2013 à 19:57

C’est con mais c’est bon à savoir : si vous avez une un tâche fabric, vous pouvez tout à fait l’appeler en dehors de fabfile dans n’importe quel script Python.

Il suffit de faire dans ce script :

from fabric.api import run, execute, env
from fabfile import la_tache
 
execute(la_tache)

Et on peut changer n’importe paramètre en le passant en keyword à execute. Par exemple pour changer l’host :

hosts = ['user@serveurdistant.com', ...]
execute(la_tache, hosts=[host])

flattr this!