fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] @hosts decorator fails in python interactive session?


From: Jeff Forcier
Subject: Re: [Fab-user] @hosts decorator fails in python interactive session?
Date: Tue, 7 Jul 2009 15:05:57 -0400

Anything relating to host lists will not work correctly interactively,
due to how Fabric currently has to execute things. Basically, it
imports your fabfile and inspects env and the functions themselves,
then figures out how many times to run each function and on which
hosts. @hosts simply sets an attribute on the function, which
fabric.main.main() knows to look for when figuring this stuff out.

Once Fabric is stable from the perspective of the base case (use via
'fab') I plan on trying to make it more flexible when used as a
library; for now that usage has to play second fiddle, as solving the
same problem for both use cases is often nontrivial.

I anticipate solving this particular problem by further breaking down
the fabric/main.py internals so you can just import a function or
class that lets you use the host-list logic on your own terms.

-Jeff

On Tue, Jul 7, 2009 at 2:56 PM, Matthew Wilson<address@hidden> wrote:
> I'm likely doing something wrong, but I can't get the hosts decorator
> to behave when I use it from within an interactive session:
>
>    >>> @hosts('jaffa.tplus1.com', 'daffodil.tplus1.com')
>    ... def hostname():
>    ...     run('hostname')
>    ...
>    >>> hostname.hosts
>    ['jaffa.tplus1.com', 'daffodil.tplus1.com']
>    >>> hostname()
>    No hosts found. Please specify (single) host string for connection:
>
> I can put all that same code into a fabfile.py and all is well:
>
>    $ cat fabfile.py
>    # vim: set expandtab ts=4 sw=4 filetype=python:
>
>    from fabric.api import hosts, run
>
>   address@hidden('jaffa.tplus1.com', 'daffodil.tplus1.com')
>    def hostname():
>        run('hostname')
>
>    $ fab hostname
>    [daffodil.tplus1.com] run: hostname
>    [daffodil.tplus1.com] out: daffodil
>    [jaffa.tplus1.com] run: hostname
>    [jaffa.tplus1.com] out: jaffa.tplus1.com
>
>    Done.
>    Disconnecting from daffodil.tplus1.com... done.
>    Disconnecting from jaffa.tplus1.com... done.
>
>
>
> --
> Matthew Wilson
> address@hidden
> http://tplus1.com
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>




reply via email to

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