Fabric name extension wants fabfile

I am working on a basic guide to Fabric Namespaces .

I was hoping to do something similar to Structuring a project with a namespace

My __init__.py file looks like:

 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 someone tell me what I am missing or something is wrong?

+4
source share
4 answers

The folder should still be named fabfile, but for documents , if you did not specify:

 $ fab -f myfolder -l 
+4
source

I had the same problem. I followed the documents http://docs.fabfile.org/en/1.8/usage/fabfiles.html#fabfile-discovery , created a module called fabfile , and I put different fabfiles in it, but when I tried to run fab -l I have Fatal error: Fabfile didn't contain any commands! .

To solve this problem, I had to import all the fabfiles into fabfile/__init__.py , for example:

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

after that I could do fab -l and get a list of all tasks in all files. The fab some_task call fab some_task also started to work.

+2
source

I also played with the fabric, and the documents are pretty thin.

in order for the fabric to load your new functions that need to be used without having to be defined inside a file called fabfile.py, so try putting your functions in this file, delete all the other files, then "fab abc" should work great !

0
source

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

My filename.py contains the contents:

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

You need to execute the command as follows: fab -f pathToFile methodnameInside.

Example: fab -f filename.py hello

0
source

Source: https://habr.com/ru/post/1414981/


All Articles