Random pep8 fixes!
This patch merely fixes a selection of files to the point where pep8 1.3.3 is happy. Most of the errors are indentation related to continued lines (E126, E127, E128), bracket positions (E124) and the use of backslash (E502). Patch 2 fixes David's comments regarding backslash and an odd comment - thanks David! Change-Id: I4fbd77ecf5395743cb96acb95fa946c322c16560
This commit is contained in:
parent
4cf96b3791
commit
9344a4a582
@ -58,7 +58,8 @@ def delete_containers(logger, conf):
|
||||
except client.ClientException, e:
|
||||
if e.http_status != HTTP_CONFLICT:
|
||||
logger.warn("Unable to delete container '%s'. "
|
||||
"Got http status '%d'." % (container, e.http_status))
|
||||
"Got http status '%d'."
|
||||
% (container, e.http_status))
|
||||
|
||||
_func_on_containers(logger, conf, 'del_concurrency', _deleter)
|
||||
|
||||
@ -179,14 +180,16 @@ class Bench(object):
|
||||
self.devices = conf.devices.split()
|
||||
self.names = names
|
||||
self.conn_pool = ConnectionPool(self.url,
|
||||
max(self.put_concurrency, self.get_concurrency,
|
||||
max(self.put_concurrency,
|
||||
self.get_concurrency,
|
||||
self.del_concurrency))
|
||||
|
||||
def _log_status(self, title):
|
||||
total = time.time() - self.beginbeat
|
||||
self.logger.info(_('%(complete)s %(title)s [%(fail)s failures], '
|
||||
'%(rate).01f/s'),
|
||||
{'title': title, 'complete': self.complete, 'fail': self.failures,
|
||||
{'title': title, 'complete': self.complete,
|
||||
'fail': self.failures,
|
||||
'rate': (float(self.complete) / total)})
|
||||
|
||||
@contextmanager
|
||||
@ -366,7 +369,8 @@ class BenchDELETE(Bench):
|
||||
else:
|
||||
node = {'ip': self.ip, 'port': self.port, 'device': device}
|
||||
direct_client.direct_delete_object(node, partition,
|
||||
self.account, container_name, name)
|
||||
self.account,
|
||||
container_name, name)
|
||||
except client.ClientException, e:
|
||||
self.logger.debug(str(e))
|
||||
self.failures += 1
|
||||
@ -394,7 +398,8 @@ class BenchGET(Bench):
|
||||
else:
|
||||
node = {'ip': self.ip, 'port': self.port, 'device': device}
|
||||
direct_client.direct_get_object(node, partition,
|
||||
self.account, container_name, name)
|
||||
self.account,
|
||||
container_name, name)
|
||||
except client.ClientException, e:
|
||||
self.logger.debug(str(e))
|
||||
self.failures += 1
|
||||
@ -430,11 +435,14 @@ class BenchPUT(Bench):
|
||||
if self.use_proxy:
|
||||
client.put_object(self.url, self.token,
|
||||
container_name, name, source,
|
||||
content_length=len(source), http_conn=conn)
|
||||
content_length=len(source),
|
||||
http_conn=conn)
|
||||
else:
|
||||
node = {'ip': self.ip, 'port': self.port, 'device': device}
|
||||
direct_client.direct_put_object(node, partition,
|
||||
self.account, container_name, name, source,
|
||||
self.account,
|
||||
container_name, name,
|
||||
source,
|
||||
content_length=len(source))
|
||||
except client.ClientException, e:
|
||||
self.logger.debug(str(e))
|
||||
|
@ -102,8 +102,9 @@ class BufferedHTTPConnection(HTTPConnection):
|
||||
response = HTTPConnection.getresponse(self)
|
||||
logging.debug(_("HTTP PERF: %(time).5f seconds to %(method)s "
|
||||
"%(host)s:%(port)s %(path)s)"),
|
||||
{'time': time.time() - self._connected_time, 'method': self._method,
|
||||
'host': self.host, 'port': self.port, 'path': self._path})
|
||||
{'time': time.time() - self._connected_time,
|
||||
'method': self._method, 'host': self.host,
|
||||
'port': self.port, 'path': self._path})
|
||||
return response
|
||||
|
||||
|
||||
|
@ -83,7 +83,8 @@ def run_daemon(klass, conf_file, section_name='', once=False, **kwargs):
|
||||
logger = kwargs.pop('logger')
|
||||
else:
|
||||
logger = utils.get_logger(conf, conf.get('log_name', section_name),
|
||||
log_to_console=kwargs.pop('verbose', False), log_route=section_name)
|
||||
log_to_console=kwargs.pop('verbose', False),
|
||||
log_route=section_name)
|
||||
|
||||
# disable fallocate if desired
|
||||
if conf.get('disable_fallocate', 'no').lower() in utils.TRUE_VALUES:
|
||||
|
@ -31,9 +31,9 @@ RUN_DIR = '/var/run/swift'
|
||||
# auth-server has been removed from ALL_SERVERS, start it explicitly
|
||||
ALL_SERVERS = ['account-auditor', 'account-server', 'container-auditor',
|
||||
'container-replicator', 'container-server', 'container-sync',
|
||||
'container-updater', 'object-auditor', 'object-server', 'object-expirer',
|
||||
'object-replicator', 'object-updater', 'proxy-server',
|
||||
'account-replicator', 'account-reaper']
|
||||
'container-updater', 'object-auditor', 'object-server',
|
||||
'object-expirer', 'object-replicator', 'object-updater',
|
||||
'proxy-server', 'account-replicator', 'account-reaper']
|
||||
MAIN_SERVERS = ['proxy-server', 'account-server', 'container-server',
|
||||
'object-server']
|
||||
REST_SERVERS = [s for s in ALL_SERVERS if s not in MAIN_SERVERS]
|
||||
@ -219,7 +219,8 @@ class Manager():
|
||||
# keep track of the pids yeiled back as killed for all servers
|
||||
killed_pids = set()
|
||||
for server, killed_pid in watch_server_pids(server_pids,
|
||||
interval=KILL_WAIT, **kwargs):
|
||||
interval=KILL_WAIT,
|
||||
**kwargs):
|
||||
print _("%s (%s) appears to have stopped") % (server, killed_pid)
|
||||
killed_pids.add(killed_pid)
|
||||
if not killed_pids.symmetric_difference(signaled_pids):
|
||||
@ -360,8 +361,8 @@ class Server():
|
||||
"""
|
||||
if self.server in STANDALONE_SERVERS:
|
||||
return pid_file.replace(
|
||||
os.path.normpath(RUN_DIR), SWIFT_DIR, 1).rsplit(
|
||||
'.pid', 1)[0] + '.conf'
|
||||
os.path.normpath(RUN_DIR), SWIFT_DIR, 1)\
|
||||
.rsplit('.pid', 1)[0] + '.conf'
|
||||
else:
|
||||
return pid_file.replace(
|
||||
os.path.normpath(RUN_DIR), SWIFT_DIR, 1).replace(
|
||||
|
@ -156,7 +156,7 @@ class MemcacheRing(object):
|
||||
flags |= JSON_FLAG
|
||||
for (server, fp, sock) in self._get_conns(key):
|
||||
try:
|
||||
sock.sendall('set %s %d %d %s noreply\r\n%s\r\n' % \
|
||||
sock.sendall('set %s %d %d %s noreply\r\n%s\r\n' %
|
||||
(key, flags, timeout, len(value), value))
|
||||
self._return_conn(server, fp, sock)
|
||||
return
|
||||
@ -225,7 +225,7 @@ class MemcacheRing(object):
|
||||
add_val = delta
|
||||
if command == 'decr':
|
||||
add_val = '0'
|
||||
sock.sendall('add %s %d %d %s\r\n%s\r\n' % \
|
||||
sock.sendall('add %s %d %d %s\r\n%s\r\n' %
|
||||
(key, 0, timeout, len(add_val), add_val))
|
||||
line = fp.readline().strip().split()
|
||||
if line[0].upper() == 'NOT_STORED':
|
||||
|
@ -108,7 +108,8 @@ def clean_acl(name, value):
|
||||
second = second[1:].strip()
|
||||
if not second or second == '.':
|
||||
raise ValueError('No host/domain value after referrer '
|
||||
'designation in ACL: %s' % repr(raw_value))
|
||||
'designation in ACL: %s' %
|
||||
repr(raw_value))
|
||||
values.append('.r:%s%s' % (negate and '-' or '', second))
|
||||
else:
|
||||
raise ValueError('Unknown designator %s in ACL: %s' %
|
||||
@ -156,8 +157,8 @@ def referrer_allowed(referrer, referrer_acl):
|
||||
for mhost in referrer_acl:
|
||||
if mhost[0] == '-':
|
||||
mhost = mhost[1:]
|
||||
if mhost == rhost or \
|
||||
(mhost[0] == '.' and rhost.endswith(mhost)):
|
||||
if mhost == rhost or (mhost[0] == '.' and
|
||||
rhost.endswith(mhost)):
|
||||
allow = False
|
||||
elif mhost == '*' or mhost == rhost or \
|
||||
(mhost[0] == '.' and rhost.endswith(mhost)):
|
||||
|
@ -67,6 +67,7 @@ for k in default_constraints:
|
||||
# tests.
|
||||
config[k] = '%s constraint is not defined' % k
|
||||
|
||||
|
||||
def load_constraint(name):
|
||||
c = config[name]
|
||||
if not isinstance(c, int):
|
||||
|
@ -93,8 +93,8 @@ class TestEmptyDevice(TestCase):
|
||||
for node in onodes[1:]:
|
||||
start_server(node['port'], self.port2server, self.pids)
|
||||
self.assertFalse(os.path.exists(obj_dir))
|
||||
# We've indirectly verified the handoff node has the object, but let's
|
||||
# directly verify it.
|
||||
# We've indirectly verified the handoff node has the object, but
|
||||
# let's directly verify it.
|
||||
another_onode = self.object_ring.get_more_nodes(opart).next()
|
||||
odata = direct_client.direct_get_object(
|
||||
another_onode, opart, self.account, container, obj)[-1]
|
||||
|
Loading…
Reference in New Issue
Block a user