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

@ -195,7 +195,7 @@ def get_account(url, token, marker=None, limit=None, prefix=None,
:param full_listing: if True, return a full listing, else returns a max
of 10000 listings
:returns: a tuple of (response headers, a list of containers) The response
headers will be a dict and all header names will be lowercase.
headers will be a dict and all header names will be lowercase.
:raises ClientException: HTTP GET request failed
"""
if not http_conn:
@ -310,7 +310,7 @@ def get_container(url, token, container, marker=None, limit=None,
:param full_listing: if True, return a full listing, else returns a max
of 10000 listings
:returns: a tuple of (response headers, a list of objects) The response
headers will be a dict and all header names will be lowercase.
headers will be a dict and all header names will be lowercase.
:raises ClientException: HTTP GET request failed
"""
if not http_conn:
@ -489,7 +489,7 @@ def get_object(url, token, container, name, http_conn=None,
the object's contents before making another
request.
:returns: a tuple of (response headers, the object's contents) The response
headers will be a dict and all header names will be lowercase.
headers will be a dict and all header names will be lowercase.
:raises ClientException: HTTP GET request failed
"""
if http_conn:

View File

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

View File

@ -89,7 +89,7 @@ def direct_get_container(node, part, account, container, marker=None,
:param conn_timeout: timeout in seconds for establishing the connection
:param response_timeout: timeout in seconds for getting the response
:returns: a tuple of (response headers, a list of objects) The response
headers will be a dict and all header names will be lowercase.
headers will be a dict and all header names will be lowercase.
"""
path = '/%s/%s' % (account, container)
qs = 'format=json'
@ -196,7 +196,7 @@ def direct_get_object(node, part, account, container, obj, conn_timeout=5,
:param response_timeout: timeout in seconds for getting the response
:param resp_chunk_size: if defined, chunk size of data to read.
:returns: a tuple of (response headers, the object's contents) The response
headers will be a dict and all header names will be lowercase.
headers will be a dict and all header names will be lowercase.
"""
path = '/%s/%s/%s' % (account, container, obj)
with Timeout(conn_timeout):

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

@ -104,8 +104,8 @@ class RingBuilder(object):
self._ring = RingData([], devs, 32 - self.part_power)
else:
self._ring = \
RingData([array('H', p2d) for p2d in self._replica2part2dev],
devs, 32 - self.part_power)
RingData([array('H', p2d) for p2d in self._replica2part2dev],
devs, 32 - self.part_power)
return self._ring
def add_dev(self, dev):

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

@ -197,7 +197,7 @@ class ObjectReplicator(Daemon):
Replicate objects.
Encapsulates most logic and data needed by the object replication process.
Each call to .replicate() performs one replication pass. It's up to the
Each call to .replicate() performs one replication pass. It's up to the
caller to do this in a loop.
"""
@ -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()