Just a bit of PEP8ing
This commit is contained in:
@@ -23,4 +23,3 @@ class AccountReplicator(db_replicator.Replicator):
|
|||||||
brokerclass = db.AccountBroker
|
brokerclass = db.AccountBroker
|
||||||
datadir = account_server.DATADIR
|
datadir = account_server.DATADIR
|
||||||
default_port = 6002
|
default_port = 6002
|
||||||
|
|
||||||
|
@@ -328,6 +328,7 @@ class AccountController(object):
|
|||||||
self.logger.info(log_message)
|
self.logger.info(log_message)
|
||||||
return res(env, start_response)
|
return res(env, start_response)
|
||||||
|
|
||||||
|
|
||||||
def app_factory(global_conf, **local_conf):
|
def app_factory(global_conf, **local_conf):
|
||||||
"""paste.deploy app factory for creating WSGI account server apps"""
|
"""paste.deploy app factory for creating WSGI account server apps"""
|
||||||
conf = global_conf.copy()
|
conf = global_conf.copy()
|
||||||
|
@@ -638,6 +638,7 @@ YOU HAVE A FEW OPTIONS:
|
|||||||
""" Used by the eventlet.wsgi.server """
|
""" Used by the eventlet.wsgi.server """
|
||||||
return self.handleREST(env, start_response)
|
return self.handleREST(env, start_response)
|
||||||
|
|
||||||
|
|
||||||
def app_factory(global_conf, **local_conf):
|
def app_factory(global_conf, **local_conf):
|
||||||
conf = global_conf.copy()
|
conf = global_conf.copy()
|
||||||
conf.update(local_conf)
|
conf.update(local_conf)
|
||||||
|
@@ -18,6 +18,7 @@ import sys
|
|||||||
import signal
|
import signal
|
||||||
from swift.common import utils
|
from swift.common import utils
|
||||||
|
|
||||||
|
|
||||||
class Daemon(object):
|
class Daemon(object):
|
||||||
"""Daemon base class"""
|
"""Daemon base class"""
|
||||||
|
|
||||||
|
@@ -37,6 +37,7 @@ class HealthCheckMiddleware(object):
|
|||||||
else:
|
else:
|
||||||
return self.app(env, start_response)
|
return self.app(env, start_response)
|
||||||
|
|
||||||
|
|
||||||
def filter_factory(global_conf, **local_conf):
|
def filter_factory(global_conf, **local_conf):
|
||||||
def healthcheck_filter(app):
|
def healthcheck_filter(app):
|
||||||
return HealthCheckMiddleware(app)
|
return HealthCheckMiddleware(app)
|
||||||
|
@@ -14,10 +14,12 @@
|
|||||||
|
|
||||||
from swift.common.memcached import MemcacheRing
|
from swift.common.memcached import MemcacheRing
|
||||||
|
|
||||||
|
|
||||||
class MemcacheMiddleware(object):
|
class MemcacheMiddleware(object):
|
||||||
"""
|
"""
|
||||||
Caching middleware that manages caching in swift.
|
Caching middleware that manages caching in swift.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, app, conf):
|
def __init__(self, app, conf):
|
||||||
self.app = app
|
self.app = app
|
||||||
self.memcache = MemcacheRing([s.strip() for s in
|
self.memcache = MemcacheRing([s.strip() for s in
|
||||||
@@ -28,6 +30,7 @@ class MemcacheMiddleware(object):
|
|||||||
env['swift.cache'] = self.memcache
|
env['swift.cache'] = self.memcache
|
||||||
return self.app(env, start_response)
|
return self.app(env, start_response)
|
||||||
|
|
||||||
|
|
||||||
def filter_factory(global_conf, **local_conf):
|
def filter_factory(global_conf, **local_conf):
|
||||||
conf = global_conf.copy()
|
conf = global_conf.copy()
|
||||||
conf.update(local_conf)
|
conf.update(local_conf)
|
||||||
|
@@ -58,6 +58,7 @@ HASH_PATH_SUFFIX = os.environ.get('SWIFT_HASH_PATH_SUFFIX', 'endcap')
|
|||||||
# Used when reading config values
|
# Used when reading config values
|
||||||
TRUE_VALUES = set(('true', '1', 'yes', 'True', 'Yes'))
|
TRUE_VALUES = set(('true', '1', 'yes', 'True', 'Yes'))
|
||||||
|
|
||||||
|
|
||||||
def load_libc_function(func_name):
|
def load_libc_function(func_name):
|
||||||
"""
|
"""
|
||||||
Attempt to find the function in libc, otherwise return a no-op func.
|
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:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def item_from_env(env, item_name):
|
def item_from_env(env, item_name):
|
||||||
item = env.get(item_name, None)
|
item = env.get(item_name, None)
|
||||||
if item is None:
|
if item is None:
|
||||||
logging.error("ERROR: %s could not be found in env!" % item_name)
|
logging.error("ERROR: %s could not be found in env!" % item_name)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
|
||||||
def cache_from_env(env):
|
def cache_from_env(env):
|
||||||
return item_from_env(env, 'swift.cache')
|
return item_from_env(env, 'swift.cache')
|
||||||
|
|
||||||
|
|
||||||
def readconf(conf, section_name, log_name=None):
|
def readconf(conf, section_name, log_name=None):
|
||||||
c = ConfigParser()
|
c = ConfigParser()
|
||||||
if not c.read(conf):
|
if not c.read(conf):
|
||||||
|
@@ -56,9 +56,9 @@ def monkey_patch_mimetools():
|
|||||||
|
|
||||||
mimetools.Message.parsetype = parsetype
|
mimetools.Message.parsetype = parsetype
|
||||||
|
|
||||||
|
|
||||||
# We might be able to pull pieces of this out to test, but right now it seems
|
# We might be able to pull pieces of this out to test, but right now it seems
|
||||||
# like more work than it's worth.
|
# like more work than it's worth.
|
||||||
|
|
||||||
def run_wsgi(conf_file, app_section, *args, **kwargs): # pragma: no cover
|
def run_wsgi(conf_file, app_section, *args, **kwargs): # pragma: no cover
|
||||||
"""
|
"""
|
||||||
Loads common settings from conf, then instantiates app and runs
|
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)
|
conf = appconfig('config:%s' % conf_file, name=app_section)
|
||||||
log_name = conf.get('log_name', app_section)
|
log_name = conf.get('log_name', app_section)
|
||||||
app = loadapp('config:%s' % conf_file,
|
app = loadapp('config:%s' % conf_file,
|
||||||
global_conf={'log_name':log_name})
|
global_conf={'log_name': log_name})
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print "Error trying to load config %s: %s" % (conf_file, e)
|
print "Error trying to load config %s: %s" % (conf_file, e)
|
||||||
return
|
return
|
||||||
|
@@ -16,10 +16,10 @@
|
|||||||
from swift.container import server as container_server
|
from swift.container import server as container_server
|
||||||
from swift.common import db, db_replicator
|
from swift.common import db, db_replicator
|
||||||
|
|
||||||
|
|
||||||
class ContainerReplicator(db_replicator.Replicator):
|
class ContainerReplicator(db_replicator.Replicator):
|
||||||
server_type = 'container'
|
server_type = 'container'
|
||||||
ring_file = 'container.ring.gz'
|
ring_file = 'container.ring.gz'
|
||||||
brokerclass = db.ContainerBroker
|
brokerclass = db.ContainerBroker
|
||||||
datadir = container_server.DATADIR
|
datadir = container_server.DATADIR
|
||||||
default_port = 6001
|
default_port = 6001
|
||||||
|
|
||||||
|
@@ -416,6 +416,7 @@ class ContainerController(object):
|
|||||||
self.logger.info(log_message)
|
self.logger.info(log_message)
|
||||||
return res(env, start_response)
|
return res(env, start_response)
|
||||||
|
|
||||||
|
|
||||||
def app_factory(global_conf, **local_conf):
|
def app_factory(global_conf, **local_conf):
|
||||||
"""paste.deploy app factory for creating WSGI container server apps"""
|
"""paste.deploy app factory for creating WSGI container server apps"""
|
||||||
conf = global_conf.copy()
|
conf = global_conf.copy()
|
||||||
|
@@ -514,7 +514,7 @@ class ObjectReplicator(Daemon):
|
|||||||
start = time.time()
|
start = time.time()
|
||||||
self.logger.info("Running object replicator in script mode.")
|
self.logger.info("Running object replicator in script mode.")
|
||||||
self.replicate()
|
self.replicate()
|
||||||
total = (time.time() - start)/60
|
total = (time.time() - start) / 60
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"Object replication complete. (%.02f minutes)" % total)
|
"Object replication complete. (%.02f minutes)" % total)
|
||||||
|
|
||||||
@@ -526,7 +526,7 @@ class ObjectReplicator(Daemon):
|
|||||||
self.logger.info("Starting object replication pass.")
|
self.logger.info("Starting object replication pass.")
|
||||||
# Run the replicator
|
# Run the replicator
|
||||||
self.replicate()
|
self.replicate()
|
||||||
total = (time.time() - start)/60
|
total = (time.time() - start) / 60
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"Object replication complete. (%.02f minutes)" % total)
|
"Object replication complete. (%.02f minutes)" % total)
|
||||||
self.logger.debug('Replication sleeping for %s seconds.' %
|
self.logger.debug('Replication sleeping for %s seconds.' %
|
||||||
|
@@ -592,6 +592,7 @@ class ObjectController(object):
|
|||||||
sleep(slow)
|
sleep(slow)
|
||||||
return res(env, start_response)
|
return res(env, start_response)
|
||||||
|
|
||||||
|
|
||||||
def app_factory(global_conf, **local_conf):
|
def app_factory(global_conf, **local_conf):
|
||||||
"""paste.deploy app factory for creating WSGI object server apps"""
|
"""paste.deploy app factory for creating WSGI object server apps"""
|
||||||
conf = global_conf.copy()
|
conf = global_conf.copy()
|
||||||
|
@@ -1138,7 +1138,7 @@ class AccountController(Controller):
|
|||||||
if error_response:
|
if error_response:
|
||||||
return error_response
|
return error_response
|
||||||
account_partition, accounts = \
|
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()),
|
headers = {'X-Timestamp': normalize_timestamp(time.time()),
|
||||||
'X-CF-Trans-Id': self.trans_id}
|
'X-CF-Trans-Id': self.trans_id}
|
||||||
headers.update(value for value in req.headers.iteritems()
|
headers.update(value for value in req.headers.iteritems()
|
||||||
@@ -1434,6 +1434,7 @@ class Application(BaseApplication):
|
|||||||
body='Slow down', request=req)
|
body='Slow down', request=req)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def app_factory(global_conf, **local_conf):
|
def app_factory(global_conf, **local_conf):
|
||||||
"""paste.deploy app factory for creating WSGI proxy apps."""
|
"""paste.deploy app factory for creating WSGI proxy apps."""
|
||||||
conf = global_conf.copy()
|
conf = global_conf.copy()
|
||||||
|
Reference in New Issue
Block a user