[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] Save session information ?
From: |
Jeff Forcier |
Subject: |
Re: [Fab-user] Save session information ? |
Date: |
Thu, 18 Oct 2012 20:39:36 -0700 |
Hi Steve,
On Thu, Oct 18, 2012 at 2:13 PM, Steve S <address@hidden> wrote:
> I'm trying to save a bit of information from a Fabric session (an md5 sum
> for a file on a remote server) for use later in the overall Python script
> and can't seem to find a way to do it, it seems everything goes away once
> the session with the server ends, it does get captured in a log file but
> that doesn't help much, anyone have a way around this or can point me in the
> right direction ?, thanks !
Pro tip: when asking for help, posting the specific code you tried, &
what the output was, really helps!
My guess is that you just need to stick the resulting info into a
module-level variable (Fabric's own 'env' object works reasonably well
for this) which is then available to other tasks or Python code
executed in the same session. For example:
from fabric.api import run, env
env.the_md5 = None
def get_that_md5():
env.the_md5 = run("md5 /some/file")
def use_that_md5():
print "The md5 was: %s" % env.the_md5
If invoked like so:
$ fab get_that_md5 use_that_md5
should work as expected, with the actual md5 string printing out at
the end. Obviously adapt for your needs :)
Best,
Jeff
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/fab-user
>
--
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org