Merge "Print pipeline names in the reported pipeline"

This commit is contained in:
Jenkins 2014-05-27 16:04:33 +00:00 committed by Gerrit Code Review
commit 373e06a6a0
2 changed files with 9 additions and 26 deletions

View File

@ -16,7 +16,6 @@
"""WSGI tools for use with swift."""
import errno
import inspect
import os
import signal
import time
@ -234,26 +233,11 @@ class PipelineWrapper(object):
return first_ctx.entry_point_name == entry_point_name
def _format_for_display(self, ctx):
if ctx.entry_point_name:
return ctx.entry_point_name
elif inspect.isfunction(ctx.object):
# ctx.object is a reference to the actual filter_factory
# function, so we pretty-print that. It's not the nice short
# entry point, but it beats "<unknown>".
#
# These happen when, instead of something like
#
# use = egg:swift#healthcheck
#
# you have something like this:
#
# paste.filter_factory = \
# swift.common.middleware.healthcheck:filter_factory
return "%s:%s" % (inspect.getmodule(ctx.object).__name__,
ctx.object.__name__)
else:
# No idea what this is
return "<unknown context>"
# Contexts specified by pipeline= have .name set in NamedConfigLoader.
if hasattr(ctx, 'name'):
return ctx.name
# This should not happen: a foreign context. Let's not crash.
return "<unknown>"
def __str__(self):
parts = [self._format_for_display(ctx)
@ -274,6 +258,7 @@ class PipelineWrapper(object):
ctx = loadwsgi.loadcontext(loadwsgi.FILTER, spec,
global_conf=self.context.global_conf)
ctx.protocol = 'paste.filter_factory'
ctx.name = entry_point_name
return ctx
def index(self, entry_point_name):

View File

@ -759,16 +759,14 @@ class TestPipelineWrapper(unittest.TestCase):
def test_str(self):
self.assertEqual(
str(self.pipe),
"healthcheck catch_errors " +
"swift.common.middleware.tempurl:filter_factory proxy")
"healthcheck catch_errors tempurl proxy-server")
def test_str_unknown_filter(self):
self.pipe.context.filter_contexts[0].entry_point_name = None
del self.pipe.context.filter_contexts[0].__dict__['name']
self.pipe.context.filter_contexts[0].object = 'mysterious'
self.assertEqual(
str(self.pipe),
"<unknown context> catch_errors " +
"swift.common.middleware.tempurl:filter_factory proxy")
"<unknown> catch_errors tempurl proxy-server")
class TestPipelineModification(unittest.TestCase):