Python中的Fabric API直接调用 [英] fabric API direct call in python

查看:115
本文介绍了Python中的Fabric API直接调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我记得可以在py脚本中直接调用Fabric API 但忘了从哪里开始 有人提供线索吗?

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

推荐答案

是的,您可以调用它,例如:

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"])

这篇关于Python中的Fabric API直接调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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