在python脚本中启动Fab File [英] Launch Fab File inside a python script

查看:99
本文介绍了在python脚本中启动Fab File的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个fab脚本,它工作正常.要启动它,我执行:

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

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

deployFilesdeployConfiguration都是我的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆