Hi. There might be a better way, but one way to do it would be to use a default value for the argument as None and warn the user if the value is still None inside your code.
Something like this:

@task
def myTask(itsargument=None):
    """ blah """
    if itsargument == None:
        usage()
        sys.exit(1)
...

Francisco Vieira

On 12/21/2012 07:52 PM, Charles Gagnon wrote:
Sorry if this is obvious but I'm very novice at Python and Fabric.
I've researched tghe documentation I could find but could find
anything for this particular case. I have a simple fabfile which
includes a task requiring an argument:

@task
def myTask(itsargument):
     """ blah """
...

It runs fine if I do:

    fab -H host fabfile.myTask:itsargument=value

It works as I want it to. But if I omit the argument, I get a
TypeError exception:

    TypeError: myTask() takes exactly 1 argument (0 given)

Which I would like to catch and output usage(). So far, I have not
been able to do so.

--
Charles Gagnon
charlesg at unixrealm.com

_______________________________________________
Fab-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user



_______________________________________________
Fab-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to