2012-05-29 48 views
4

我正在通過Fabric Namespaces上的基本教程。Fabric命名空間需要一個fabfile

我希望做同樣的事情到Structuring a fabric project with namespaces

__init__.py文件如下:

from fabric.api import task 

@task 
def abc(): 
    pass 

當我運行fab --list我得到這個錯誤:

[email protected]:/tmp/fabric_test$ fab --list 

Fatal error: Couldn't find any fabfiles! 

Remember that -f can be used to specify fabfile path, and use -h for help. 

Aborting. 

誰能告訴我是什麼我失蹤或做錯了?

回答

4

文件夾仍然需要fabfile命名,如per the docs,除非你指定:

$ fab -f myfolder -l 
+1

我覺得自己很蠢。我幾次閱讀那個頁面。謝謝:) – victorawesome

+0

不用擔心,這是一個很明顯的小節。這些文檔是透徹的,但是在少數幾個地方用單個句子表達的內容很簡單而且相當密集。 – Morgan

0

我只是用布耍得,和文檔是非常薄。

用於織物來拾取您使用的新功能而不使用-f您需要將它們定義在名爲fabfile.py的文件中,因此請嘗試將您的功能放在此文件中,刪除所有其他文件,然後'fab abc'應該工作很棒!

2

我有同樣的問題。我遵循文檔http://docs.fabfile.org/en/1.8/usage/fabfiles.html#fabfile-discovery,建立一個名爲fabfile的模塊,並在其中放入不同的fabfiles,但是當我嘗試運行fab -l時,出現錯誤Fatal error: Fabfile didn't contain any commands!

爲了解決這個問題,我不得不進口所有fabfiles在fabfile/__init__.py,像這樣:

from myfab_1 import * 
from other_fab import * 
from other_tasks import * 

在此之後,我可以做fab -l並得到了所有任務中的所有文件的列表。撥打fab some_task也開始工作。

0

如果要執行比fabfile,恩以外的任何其他名稱的文件:filename.py

我filename.py包含的內容:

def hello(): 
    print ("Hello world") 

你必須這樣執行的命令: fab -f pathToFile methodnameInside.

例子:fab -f filename.py hello

相關問題