结构命名空间需要一个晶圆厂文件



我正在学习有关结构命名空间的基本教程。

我希望做一些类似于使用命名空间构建结构项目的事情

我的__init__.py文件看起来:

from fabric.api import task
@task
def abc():
   pass

当我运行fab --list时出现此错误:

me@galvatron:/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.

谁能告诉我我错过了什么或做错了什么?

根据文档,该文件夹仍需要命名为 fabfile,除非您指定:

$ fab -f myfolder -l

我遇到了同样的问题。我按照文档 http://docs.fabfile.org/en/1.8/usage/fabfiles.html#fabfile-discovery,构建了一个名为 fabfile 的模块,并在其中放置了不同的 fabfile,但是当我尝试运行 fab -l 时,我Fatal error: Fabfile didn't contain any commands!出现错误。

为了解决这个问题,我必须在fabfile/__init__.py中导入所有fabfile,如下所示:

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

在此之后,我可以做fab -l并得到所有文件中所有任务的列表。呼叫fab some_task也开始工作。

我也

只是在玩织物,而且文档很薄。

为了让 fabric 在没有 -f 的情况下使用您的新函数,您需要在一个名为 fabfile.py 的文件中定义它们,因此请尝试将您的函数放在此文件中,删除所有其他文件,然后"fab abc"应该可以正常工作!

如果要执行除 fabfile 以外的任何其他名称的文件,例如:filename.py

我的 filename.py 包含以下内容:

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

你必须像这样执行命令: fab -f pathToFile methodnameInside.

示例:fab -f filename.py hello

最新更新