Just a bit of PEP8ing

This commit is contained in:
gholt
2010-09-15 20:52:54 -07:00
parent 9b9c64d27c
commit c138ad99a2
16 changed files with 28 additions and 15 deletions

View File

@@ -23,4 +23,3 @@ class AccountReplicator(db_replicator.Replicator):
brokerclass = db.AccountBroker
datadir = account_server.DATADIR
default_port = 6002

View File

@@ -328,6 +328,7 @@ class AccountController(object):
self.logger.info(log_message)
return res(env, start_response)
def app_factory(global_conf, **local_conf):
"""paste.deploy app factory for creating WSGI account server apps"""
conf = global_conf.copy()

View File

@@ -638,6 +638,7 @@ YOU HAVE A FEW OPTIONS:
""" Used by the eventlet.wsgi.server """
return self.handleREST(env, start_response)
def app_factory(global_conf, **local_conf):
conf = global_conf.copy()
conf.update(local_conf)

View File

@@ -18,6 +18,7 @@ import sys
import signal
from swift.common import utils
class Daemon(object):
"""Daemon base class"""

View File

@@ -37,6 +37,7 @@ class HealthCheckMiddleware(object):
else:
return self.app(env, start_response)
def filter_factory(global_conf, **local_conf):
def healthcheck_filter(app):
return HealthCheckMiddleware(app)

View File

@@ -14,10 +14,12 @@
from swift.common.memcached import MemcacheRing
class MemcacheMiddleware(object):
"""
Caching middleware that manages caching in swift.
"""
def __init__(self, app, conf):
self.app = app
self.memcache = MemcacheRing([s.strip() for s in
@@ -28,6 +30,7 @@ class MemcacheMiddleware(object):
env['swift.cache'] = self.memcache
return self.app(env, start_response)
def filter_factory(global_conf, **local_conf):
conf = global_conf.copy()
conf.update(local_conf)

View File

@@ -58,6 +58,7 @@ HASH_PATH_SUFFIX = os.environ.get('SWIFT_HASH_PATH_SUFFIX', 'endcap')
# Used when reading config values
TRUE_VALUES = set(('true', '1', 'yes', 'True', 'Yes'))
def load_libc_function(func_name):
"""
Attempt to find the function in libc, otherwise return a no-op func.
@@ -521,15 +522,18 @@ def unlink_older_than(path, mtime):
except OSError:
pass
def item_from_env(env, item_name):
item = env.get(item_name, None)
if item is None:
logging.error("ERROR: %s could not be found in env!" % item_name)
return item
def cache_from_env(env):
return item_from_env(env, 'swift.cache')
def readconf(conf, section_name, log_name=None):
c = ConfigParser()
if not c.read(conf):

View File

@@ -56,9 +56,9 @@ def monkey_patch_mimetools():
mimetools.Message.parsetype = parsetype
# We might be able to pull pieces of this out to test, but right now it seems
# like more work than it's worth.
def run_wsgi(conf_file, app_section, *args, **kwargs): # pragma: no cover
"""
Loads common settings from conf, then instantiates app and runs
@@ -72,7 +72,7 @@ def run_wsgi(conf_file, app_section, *args, **kwargs): # pragma: no cover
conf = appconfig('config:%s' % conf_file, name=app_section)
log_name = conf.get('log_name', app_section)
app = loadapp('config:%s' % conf_file,
global_conf={'log_name':log_name})
global_conf={'log_name': log_name})
except Exception, e:
print "Error trying to load config %s: %s" % (conf_file, e)
return

View File

@@ -16,10 +16,10 @@
from swift.container import server as container_server
from swift.common import db, db_replicator
class ContainerReplicator(db_replicator.Replicator):
server_type = 'container'
ring_file = 'container.ring.gz'
brokerclass = db.ContainerBroker
datadir = container_server.DATADIR
default_port = 6001

View File

@@ -416,6 +416,7 @@ class ContainerController(object):
self.logger.info(log_message)
return res(env, start_response)
def app_factory(global_conf, **local_conf):
"""paste.deploy app factory for creating WSGI container server apps"""
conf = global_conf.copy()

View File

@@ -514,7 +514,7 @@ class ObjectReplicator(Daemon):
start = time.time()
self.logger.info("Running object replicator in script mode.")
self.replicate()
total = (time.time() - start)/60
total = (time.time() - start) / 60
self.logger.info(
"Object replication complete. (%.02f minutes)" % total)
@@ -526,7 +526,7 @@ class ObjectReplicator(Daemon):
self.logger.info("Starting object replication pass.")
# Run the replicator
self.replicate()
total = (time.time() - start)/60
total = (time.time() - start) / 60
self.logger.info(
"Object replication complete. (%.02f minutes)" % total)
self.logger.debug('Replication sleeping for %s seconds.' %

View File

@@ -592,6 +592,7 @@ class ObjectController(object):
sleep(slow)
return res(env, start_response)
def app_factory(global_conf, **local_conf):
"""paste.deploy app factory for creating WSGI object server apps"""
conf = global_conf.copy()

View File

@@ -1138,7 +1138,7 @@ class AccountController(Controller):
if error_response:
return error_response
account_partition, accounts = \
self.app.account_ring.get_nodes( self.account_name)
self.app.account_ring.get_nodes(self.account_name)
headers = {'X-Timestamp': normalize_timestamp(time.time()),
'X-CF-Trans-Id': self.trans_id}
headers.update(value for value in req.headers.iteritems()
@@ -1434,6 +1434,7 @@ class Application(BaseApplication):
body='Slow down', request=req)
return None
def app_factory(global_conf, **local_conf):
"""paste.deploy app factory for creating WSGI proxy apps."""
conf = global_conf.copy()