fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] editing remote files with vim


From: Jeff Forcier
Subject: Re: [Fab-user] editing remote files with vim
Date: Tue, 16 Feb 2010 08:35:57 -0500

Hi Edoardo,

On Tue, Feb 16, 2010 at 6:57 AM, Edoardo Batini <address@hidden> wrote:
> Hi,
> which is the best way to edit remote files using fabric?

There's no way to run fully interactive programs with Fabric at this
time, so unfortunately you'll have to come up with some noninteractive
method of effecting changes to remote files.

I often use fabric.contrib.files.(sed|append|comment|uncomment) to
script minor changes to remote files; and of course there's the main
API calls get()/put() for upload/download. Depending on your needs,
you might want to consider using prompt() or local() alongside the
abovementioned functions.

E.g. if you need to make simple-but-unscriptable changes, get some
input from the user with prompt() and use that in a call to sed(). Or,
more robustly, write a helper function (semi-pseudocode):

    def edit(remote_path):
        local_path = tmpfile(remote_path)
        get(remote_path, local_path)
        local("vim %s" % local_path)
        put(remote_path, local_path)

(In fact, I could easily see such a function showing up in
fabric.contrib.files, at least if no fully-interactive mode is
implemented in the near future.)

Hope that helps,
Jeff

-- 
Jeff Forcier
Unix sysadmin; Python/Ruby developer
http://bitprophet.org




reply via email to

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