fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] Executing script on localhost without ssh


From: Jeff Forcier
Subject: Re: [Fab-user] Executing script on localhost without ssh
Date: Mon, 7 Sep 2009 23:01:11 -0400

On Mon, Sep 7, 2009 at 9:53 PM, Taras Mankovski<address@hidden> wrote:

> I think local should be more like a context(or environment), rather
> then a function for executing commands.

I guess I'm still not convinced as to why this is necessary? It sounds like
you're proposing that local() be replaced with a "SSH to localhost"
functionality, which might be a roundabout way of removing the current "local !=
run" issues, but still seems kind of odd, and the main point of local() is
for folks to tinker with stuff on the local machine, which may well not have
SSH.

Can you give me a concrete example of what you're trying to accomplish which
isn't well served by the current setup, and which would be solved by your
proposed change? I think this is necessary for us to move forward with
the discussion.

I'll tackle some other aspects of your email below:

> def local():
>     env.hosts['localhost']
>
> I think it would be more elegant to say:
>
> def setup():
>     run('command on remote server')
>     sudo('command on remote server')
>     with local():
>          sudo('local command')

This is possible now, actually:

    def setup():
        run('x')
        sudo('y')
        with settings(host_string='localhost'):
            sudo('z')

This uses the existing settings() (env-modifying) context manager, and works
because sudo and run don't look at env.hosts, but only at the "current host
string", which is stored in env.host_string, when they figure out what to
connect to. (I'll probably tweak this in 1.0 to make it sound a bit
better / make
it easier to manipulate the run/sudo target in mid-task.)

> And this syntax would also work for Virtualenv as well.

There are existing plans to do just this, and make a generic cd-like
context manager:

    http://code.fabfile.org/issues/show/23

This is relatively high on my priority list, FYI :) as it would be quite useful.

Best,
Jeff




reply via email to

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