fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] logging to file?


From: Nicolas Michel
Subject: Re: [Fab-user] logging to file?
Date: Thu, 26 Jan 2012 08:23:03 +0100

Hello,

There is another solution that takes more time and code but I use it when need something clean :
- execute your code with that : 

from fabric.context_managers import hide
 
def myjob():
  with hide('everything'):
    your code
 
- use the open python builtin with append mode ('a') to write whatever you want to a file
- you'll also probably wanted to use env.warn_only=True so you'll be able to catch errors with return_code property :
result = run("my command")
if result.return_code == 0:
  something
else:
  something

Nicolas

2012/1/25 Jeff Forcier <address@hidden>
On Wed, Jan 25, 2012 at 10:24 AM, Chris Withers <address@hidden> wrote:

> - when does fabric write to stderr versus stdout?

It tries to be "Unix-y", so normal information like "Running task 'x'"
and such goes to stdout; errors/aborts/tracebacks should go to stderr;
remote stdout/stderr are sent to the appropriate local stream; etc.

> - what happens with password prompts and the like?

Those won't work well when redirecting, no, so you'd have to ensure
your task(s) can be run noninteractively by setting Fab env vars like
env.password, using ssh keys, those sorts of things.

-Jeff

>
>
> cheers,
>
> Chris
>
> --
> Simplistix - Content Management, Batch Processing & Python Consulting
>            - http://www.simplistix.co.uk
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/fab-user



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

_______________________________________________
Fab-user mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fab-user



--
Nicolas MICHEL

reply via email to

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