简体   繁体   中英

Fabric namespacing wants a fabfile

I'm working through the basic tutorial on Fabric Namespaces .

I was hoping to do something similar to Structuring a fabric project with namespaces

My __init__.py file looks:

from fabric.api import task

@task
def abc():
   pass

When I run fab --list I get this error:

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.

Can anyone tell me what I'm missing or doing wrong?

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

$ fab -f myfolder -l

I had same issue. I followed the docs http://docs.fabfile.org/en/1.8/usage/fabfiles.html#fabfile-discovery , build a module named fabfile and in it i've put different fabfiles, but when i tried to run fab -l i got an error Fatal error: Fabfile didn't contain any commands! .

To solve this issue i had to import all fabfiles in fabfile/__init__.py , like so:

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

after this, i could do fab -l and got a list of all tasks in all the files. Calling fab some_task started working as well.

I was just playing with fabric too, and the docs are pretty thin.

for fabric to pickup your new functions to be used without -f you need to have them defined inside a file called fabfile.py so try putting your functions in this file, delete all other files, then 'fab abc' should work great!

If you want to execute a file with any other name other than fabfile, ex: filename.py

My filename.py contains content:

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

You have to execute command like this: fab -f pathToFile methodnameInside.

Example: fab -f filename.py hello

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM