在python脚本中启动Fab File [英] Launch Fab File inside a python script
问题描述
我有一个fab
脚本,它工作正常.要启动它,我执行:
I have a fab
script, it works fine. To start it, I execute:
fab -H 192.168.xx.xx deployFiles deployConfiguration:'master',7
deployFiles
和deployConfiguration
都是我的fabfile.py
中的功能. 'master'
和7
是我的deployConfiguration
deployFiles
and deployConfiguration
are both functions in my fabfile.py
. 'master'
and 7
are my parameters for deployConfiguration
我还有另一个Python脚本,我想启动他内部的上一个fab
命令.
I have another Python script and I want to launch, the previous fab
command inside him.
如何使用Python脚本中的这些参数执行我的fabfile?
How can I execute, my fabfile with these parameters from a Python script?
推荐答案
您只需导入它们,然后对其进行调用.使用设置上下文管理器或在fabric.api.env
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='user@192.168.xx.xx'):
deployFiles()
deployConfiguration('master', 7)
这篇关于在python脚本中启动Fab File的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!