replace fabric.tasks.execute(hello) with execute(hello)

On 19 February 2013 22:48, Ryan Langford <[email protected]> wrote:

> 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:
>
> user@host:~/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 <[email protected]> wrote:
> > On Tue, Feb 19, 2013 at 12:33 PM, Ryan Langford <[email protected]>
> 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
> >> [email protected]
> >> https://lists.nongnu.org/mailman/listinfo/fab-user
> >
> >
> >
> > --
> > Jeff Forcier
> > Unix sysadmin; Python/Ruby engineer
> > http://bitprophet.org
>
> _______________________________________________
> 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