fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] Fabric as a Library and fabfile


From: Ryan Langford
Subject: Re: [Fab-user] Fabric as a Library and fabfile
Date: Tue, 19 Feb 2013 14:48:22 -0600

Thanks Jeff,

I'm new to both Python and fabric, so I'm not sure where my difficulty
lies, although I suspect it's more due to my lack of knowledge about
Python .  Here's my sample code:

#!/usr/bin/env python
#from fabric.api import *

import sys
sys.path.append("/path/to/fabfile")
import ryanfab

fabric.tasks.execute(hello)

And here's what I get on the console:

address@hidden:~/fab-import$ ./test.py
Traceback (most recent call last):
  File "./test.py", line 8, in <module>
    fabric.tasks.execute(hello)
NameError: name 'fabric' is not defined


Where am I going wrong?

Thanks,

Ryan

On Tue, Feb 19, 2013 at 2:37 PM, Jeff Forcier <address@hidden> wrote:
> On Tue, Feb 19, 2013 at 12:33 PM, Ryan Langford <address@hidden> wrote:
>> Hello,
>>
>> How do I properly load fabric as a library in a python script and get
>> it to leverage a fabfile?
>
>
> Hi Ryan,
>
> First, see http://docs.fabfile.org/en/1.5/usage/library.html for
> details on what it means to use Fab as a library.
>
> Second, re: a fabfile, when not used via 'fab' fabfiles are literally
> just Python modules, same as anything else. Import the specific
> subroutines you want to use, and call them using the 'execute()'
> function (as outlined in that link). execute() honors decorators and
> such so you can often get similar behavior to what 'fab' would do for
> a given task.
>
> Best,
> Jeff
>
>
>>
>> Thanks,
>>
>> Ryan
>>
>> _______________________________________________
>> Fab-user mailing list
>> address@hidden
>> https://lists.nongnu.org/mailman/listinfo/fab-user
>
>
>
> --
> Jeff Forcier
> Unix sysadmin; Python/Ruby engineer
> http://bitprophet.org



reply via email to

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