fabric - 怎么使用 python 直接运行 fabfiles, 而不是通过 fab?
大家讲道理
大家讲道理 2017-04-18 09:32:00
0
3
391

是的, 我知道使用 fab 能执行 fabfiles , 但我想通过 python 直接运行 fab task, 而不是通过 fab, 请问该怎么做?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(3)
巴扎黑

The solution has been found, execute(fab_fun) can be run directly

PHPzhong

Encapsulate it into a new script

左手右手慢动作

Same as above, encapsulate the fab command into a script

test.py script content

#!/usr/bin/env python

import subprocess

p = subprocess.Popen("/usr/bin/fab uname_a",shell=True)
p.wait()

fabfile.py content:

#!/usr/bin/env python

from fabric.api import *
from fabric.colors import red

env.abort_exception = True


def uname_a():
    run("uname -a")  

Originally, fab uname_a was executed to execute the fab command. Now use python test.py

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template