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: Charles Gagnon
Subject: Re: [Fab-user] Exceptions on tasks
Date: Fri, 21 Dec 2012 15:26:23 -0500

That actually works great for me. Thanks.

On Fri, Dec 21, 2012 at 3:14 PM, Francisco José Marques Vieira
<address@hidden> wrote:
> 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
>>
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/fab-user



-- 
Charles Gagnon
charlesg at unixrealm.com



reply via email to

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