是的, 我知道使用 fab 能执行 fabfiles , 但我想通过 python 直接运行 fab task, 而不是通过 fab, 请问该怎么做?
ringa_lee2017-04-18 09:34:00
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