Swap stdout/stderr -- debug messages then go to stderr, and yaml data to stdout

This commit is contained in:
Wesley Spikes 2011-07-18 17:04:36 -07:00
parent ce6c57841a
commit 0297d61e40
3 changed files with 8 additions and 1 deletions

View file

@ -4,6 +4,7 @@ import itertools
import os
import random
import string
import sys
import yaml
s3 = bunch.Bunch()
@ -13,6 +14,10 @@ prefix = ''
# For those scripts that use a context, these are pretty univerally needed.
context = bunch.Bunch(
bucket = None,
# Save stdout/stderr in case they get fudged with.
real_stdout = sys.stdout,
real_stderr = sys.stderr,
)
bucket_counter = itertools.count(1)

View file

@ -93,7 +93,7 @@ class ResultsLogger(gevent.Greenlet):
""" A quick little greenlet to always run and dump results. """
def __init__(self):
gevent.Greenlet.__init__(self)
self.outfile = sys.stderr
self.outfile = context.real_stdout
def _run(self):
while True:

View file

@ -10,6 +10,7 @@ import random
import realistic
import time
import traceback
import sys
import common
from common import context, config
@ -86,6 +87,7 @@ def _main():
def main():
sys.stdout = sys.stderr # Original steam already saved by common
common.setup()
setup()