Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch Fab File inside a python script

Tags:

python

fabric

I have a fab script, it works fine. To start it, I execute:

fab -H 192.168.xx.xx deployFiles deployConfiguration:'master',7

deployFiles and deployConfiguration are both functions in my fabfile.py. 'master' and 7 are my parameters for deployConfiguration

I have another Python script and I want to launch, the previous fab command inside him.

How can I execute, my fabfile with these parameters from a Python script?

like image 270
Matt Avatar asked Dec 11 '22 23:12

Matt


1 Answers

You just import them, and call them. Using either the settings context manager or setting the relevant settings on fabric.api.env

from fabric.context_managers import settings
from fabfile import deployFiles, deployConfiguration

with settings(host_string='[email protected]'):
    deployFiles()
    deployConfiguration('master', 7)
like image 189
aychedee Avatar answered Dec 29 '22 11:12

aychedee