本文介绍了用于面料的独立fabfile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使fabfile独立?
我不太喜欢运行外部工具"fab".如果我设法独立获得fabfile,则可以从(Eclipse/Pydev)IDE内运行该文件,轻松调试它,使用项目配置和路径等.
为什么这样行不通:

Is it possible to make the fabfile stand-alone?
I'm not very fond of running the external tool 'fab'. If I manage to get the fabfile standalone I can run the file from within the (Eclipse / Pydev) IDE, easily debug it, use project configurations and paths etc.
Why doesn't this work:

from fabric.api import run

def host_type():
    run('uname -s')

if __name__ == '__main__':
    host_type()    

推荐答案

我最终找到了解决方案(而且确实很简单!).
在我的fabfile中,我添加了:

I eventually found the solution (and it is really simple!).
In my fabfile, I added:

from fabric.main import main

if __name__ == '__main__':
    import sys
    sys.argv = ['fab', '-f', __file__, 'update_server']
    main()

我希望这可以帮助人们...

I hope this helps people...

这篇关于用于面料的独立fabfile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 18:29