fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] Reading a remote file into memory


From: Jon Dufresne
Subject: Re: [Fab-user] Reading a remote file into memory
Date: Fri, 11 Oct 2013 08:34:06 -0700

Thanks! I like the idea behind the StrionIO solution. I'll be using
that. Thanks for the help.

On Thu, Oct 10, 2013 at 6:09 PM, Jeff Forcier <address@hidden> wrote:
> Hi Jon,
>
> Depends on the file. You certainly can use run('cat') and then
> interact with the stdout value (run()'s return acts like a string
> containing stdout, by default).
>
> For anything that doesn't play nice with that (e.g. funky nonprinting
> characters) the put/get functions can take StringIO arguments for the
> 'local' side of things, so you should be able to do e.g.:
>
>     contents = StringIO()
>     get('/path/to/file', contents)
>     # operate on 'contents' like a file object here, e.g. 'print
> contents.getvalue()'
>
> -Jeff
>
> On Thu, Oct 10, 2013 at 4:16 AM, Jon Dufresne <address@hidden> wrote:
>> Hi,
>>
>> What is considered the best way to read a remote file into memory to
>> be used by Python or Fabric? Should I shell out to cat on the server
>> "contents = run('cat /path/to/file')" or is there a better way?
>>
>> My Fabric file requires parsing a file to continue other operations on
>> the server.
>>
>> Thanks,
>> Jon
>>
>> _______________________________________________
>> 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]