pythonfabric

New to python fabric and not able to run basic code


I have a basic code which doesn't run:

def hello():
    print("uptime")

When I run the following command in terminal fab hello

I get this error:

No idea what 'hello' is!


Solution

  • The issue is that the new fabric task method (as discussed here - http://docs.fabfile.org/en/1.14/usage/tasks.html) is to use the @task decorator. The equivalent example for your code is:

    from fabric import task
    
    @task
    def hello():
      print("uptime")
    

    Running fab hello should yield the expected output.

    Source: https://github.com/fabric/fabric/issues/1854#issuecomment-414639606