fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] Exceptions on tasks


From: Francisco José Marques Vieira
Subject: Re: [Fab-user] Exceptions on tasks
Date: Fri, 21 Dec 2012 20:14:56 +0000
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0

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
address@hidden
https://lists.nongnu.org/mailman/listinfo/fab-user





reply via email to

[Prev in Thread] Current Thread [Next in Thread]