From 0297d61e40b81d9ebb154f3225478991b3483a5f Mon Sep 17 00:00:00 2001 From: Wesley Spikes Date: Mon, 18 Jul 2011 17:04:36 -0700 Subject: [PATCH] Swap stdout/stderr -- debug messages then go to stderr, and yaml data to stdout --- s3tests/common/__init__.py | 5 +++++ s3tests/common/results.py | 2 +- s3tests/roundtrip.py | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/s3tests/common/__init__.py b/s3tests/common/__init__.py index a64fe10..8eb4232 100644 --- a/s3tests/common/__init__.py +++ b/s3tests/common/__init__.py @@ -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) diff --git a/s3tests/common/results.py b/s3tests/common/results.py index 2a3da10..b9aa9ce 100644 --- a/s3tests/common/results.py +++ b/s3tests/common/results.py @@ -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: diff --git a/s3tests/roundtrip.py b/s3tests/roundtrip.py index c69fb94..69b35a1 100644 --- a/s3tests/roundtrip.py +++ b/s3tests/roundtrip.py @@ -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()