summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2015-07-29 23:46:58 +0200
committerVictor Stinner <vstinner@redhat.com>2015-07-30 09:33:41 +0200
commit389a97e3526df68121cecfaf1909343b5d381cbc (patch)
tree4998af7771b96058e160ca54ac18391d647ec2d5
parentd719064e788ec5fa70305fadaa46affcb603a9bb (diff)
downloadswift-389a97e3526df68121cecfaf1909343b5d381cbc.tar.gz
Fix pep8 E warning for hacking 0.10
Fix pep8 warnings of the E category of hacking 0.10: * E113: unexpected indentation * E121: continuation line under-indented for hanging indent * E122: continuation line missing indentation or outdented * E123: closing bracket does not match indentation of opening bracket's line * E126: continuation line over-indented for hanging indent * E251: unexpected spaces around keyword / parameter equals Change-Id: I0b24eebdf1a37dc1b572b6c9a3d3d4832d050237
-rw-r--r--swift/account/auditor.py9
-rw-r--r--swift/common/direct_client.py4
-rw-r--r--swift/common/middleware/tempauth.py30
-rw-r--r--swift/obj/reconstructor.py21
-rw-r--r--swift/proxy/server.py10
-rw-r--r--test/unit/container/test_server.py6
-rwxr-xr-xtest/unit/obj/test_server.py18
-rw-r--r--test/unit/proxy/test_server.py9
8 files changed, 50 insertions, 57 deletions
diff --git a/swift/account/auditor.py b/swift/account/auditor.py
index 261acf7e9..0f72999b9 100644
--- a/swift/account/auditor.py
+++ b/swift/account/auditor.py
@@ -122,11 +122,10 @@ class AccountAuditor(Daemon):
continue
raise InvalidAccountInfo(_(
'The total %(key)s for the container (%(total)s) does not '
- 'match the sum of %(key)s across policies (%(sum)s)') % {
- 'key': key,
- 'total': info[key],
- 'sum': policy_totals[key],
- })
+ 'match the sum of %(key)s across policies (%(sum)s)')
+ % {'key': key,
+ 'total': info[key],
+ 'sum': policy_totals[key]})
def account_audit(self, path):
"""
diff --git a/swift/common/direct_client.py b/swift/common/direct_client.py
index 8ba1e5e11..3058309b8 100644
--- a/swift/common/direct_client.py
+++ b/swift/common/direct_client.py
@@ -543,8 +543,8 @@ def retry(func, *args, **kwargs):
# Shouldn't actually get down here, but just in case.
if args and 'ip' in args[0]:
raise ClientException('Raise too many retries',
- http_host=args[
- 0]['ip'], http_port=args[0]['port'],
+ http_host=args[0]['ip'],
+ http_port=args[0]['port'],
http_device=args[0]['device'])
else:
raise ClientException('Raise too many retries')
diff --git a/swift/common/middleware/tempauth.py b/swift/common/middleware/tempauth.py
index 15c3a4a03..5e3f980e6 100644
--- a/swift/common/middleware/tempauth.py
+++ b/swift/common/middleware/tempauth.py
@@ -674,15 +674,15 @@ class TempAuth(object):
user = req.headers.get('x-auth-user')
if not user or ':' not in user:
self.logger.increment('token_denied')
- return HTTPUnauthorized(request=req, headers=
- {'Www-Authenticate':
- 'Swift realm="%s"' % account})
+ auth = 'Swift realm="%s"' % account
+ return HTTPUnauthorized(request=req,
+ headers={'Www-Authenticate': auth})
account2, user = user.split(':', 1)
if account != account2:
self.logger.increment('token_denied')
- return HTTPUnauthorized(request=req, headers=
- {'Www-Authenticate':
- 'Swift realm="%s"' % account})
+ auth = 'Swift realm="%s"' % account
+ return HTTPUnauthorized(request=req,
+ headers={'Www-Authenticate': auth})
key = req.headers.get('x-storage-pass')
if not key:
key = req.headers.get('x-auth-key')
@@ -692,9 +692,9 @@ class TempAuth(object):
user = req.headers.get('x-storage-user')
if not user or ':' not in user:
self.logger.increment('token_denied')
- return HTTPUnauthorized(request=req, headers=
- {'Www-Authenticate':
- 'Swift realm="unknown"'})
+ auth = 'Swift realm="unknown"'
+ return HTTPUnauthorized(request=req,
+ headers={'Www-Authenticate': auth})
account, user = user.split(':', 1)
key = req.headers.get('x-auth-key')
if not key:
@@ -711,14 +711,14 @@ class TempAuth(object):
account_user = account + ':' + user
if account_user not in self.users:
self.logger.increment('token_denied')
- return HTTPUnauthorized(request=req, headers=
- {'Www-Authenticate':
- 'Swift realm="%s"' % account})
+ auth = 'Swift realm="%s"' % account
+ return HTTPUnauthorized(request=req,
+ headers={'Www-Authenticate': auth})
if self.users[account_user]['key'] != key:
self.logger.increment('token_denied')
- return HTTPUnauthorized(request=req, headers=
- {'Www-Authenticate':
- 'Swift realm="unknown"'})
+ auth = 'Swift realm="unknown"'
+ return HTTPUnauthorized(request=req,
+ headers={'Www-Authenticate': auth})
account_id = self.users[account_user]['url'].rsplit('/', 1)[-1]
# Get memcache client
memcache_client = cache_from_env(req.environ)
diff --git a/swift/obj/reconstructor.py b/swift/obj/reconstructor.py
index 9f8fb23e1..cfe6239c2 100644
--- a/swift/obj/reconstructor.py
+++ b/swift/obj/reconstructor.py
@@ -319,11 +319,11 @@ class ObjectReconstructor(Daemon):
except (Exception, Timeout):
self.logger.exception(
_("Error trying to rebuild %(path)s "
- "policy#%(policy)d frag#%(frag_index)s"), {
- 'path': path,
- 'policy': policy,
- 'frag_index': frag_index,
- })
+ "policy#%(policy)d frag#%(frag_index)s"),
+ {'path': path,
+ 'policy': policy,
+ 'frag_index': frag_index,
+ })
break
if not all(fragment_payload):
break
@@ -486,14 +486,11 @@ class ObjectReconstructor(Daemon):
self._full_path(node, job['partition'], '',
job['policy']))
elif resp.status != HTTP_OK:
+ full_path = self._full_path(node, job['partition'], '',
+ job['policy'])
self.logger.error(
- _("Invalid response %(resp)s "
- "from %(full_path)s"), {
- 'resp': resp.status,
- 'full_path': self._full_path(
- node, job['partition'], '',
- job['policy'])
- })
+ _("Invalid response %(resp)s from %(full_path)s"),
+ {'resp': resp.status, 'full_path': full_path})
else:
remote_suffixes = pickle.loads(resp.read())
except (Exception, Timeout):
diff --git a/swift/proxy/server.py b/swift/proxy/server.py
index b631542f6..65044a186 100644
--- a/swift/proxy/server.py
+++ b/swift/proxy/server.py
@@ -569,11 +569,11 @@ class Application(object):
else:
log = self.logger.exception
log(_('ERROR with %(type)s server %(ip)s:%(port)s/%(device)s'
- ' re: %(info)s'), {
- 'type': typ, 'ip': node['ip'], 'port':
- node['port'], 'device': node['device'],
- 'info': additional_info
- }, **kwargs)
+ ' re: %(info)s'),
+ {'type': typ, 'ip': node['ip'],
+ 'port': node['port'], 'device': node['device'],
+ 'info': additional_info},
+ **kwargs)
def modify_wsgi_pipeline(self, pipe):
"""
diff --git a/test/unit/container/test_server.py b/test/unit/container/test_server.py
index 5fd3da340..e500fdd9e 100644
--- a/test/unit/container/test_server.py
+++ b/test/unit/container/test_server.py
@@ -940,9 +940,9 @@ class TestContainerController(unittest.TestCase):
snowman = u'\u2603'
container_name = snowman.encode('utf-8')
req = Request.blank(
- '/sda1/p/a/%s' % container_name, environ={
- 'REQUEST_METHOD': 'PUT',
- 'HTTP_X_TIMESTAMP': '1'})
+ '/sda1/p/a/%s' % container_name,
+ environ={'REQUEST_METHOD': 'PUT',
+ 'HTTP_X_TIMESTAMP': '1'})
resp = req.get_response(self.controller)
self.assertEquals(resp.status_int, 201)
diff --git a/test/unit/obj/test_server.py b/test/unit/obj/test_server.py
index 7a5dff5a4..d777edf2b 100755
--- a/test/unit/obj/test_server.py
+++ b/test/unit/obj/test_server.py
@@ -2240,12 +2240,11 @@ class TestObjectController(unittest.TestCase):
self.assertEquals(len(os.listdir(os.path.dirname(ts_1000_file))), 1)
orig_timestamp = utils.Timestamp(1002).internal
+ headers = {'X-Timestamp': orig_timestamp,
+ 'Content-Type': 'application/octet-stream',
+ 'Content-Length': '4'}
req = Request.blank('/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
- headers={
- 'X-Timestamp': orig_timestamp,
- 'Content-Type': 'application/octet-stream',
- 'Content-Length': '4',
- })
+ headers=headers)
req.body = 'test'
resp = req.get_response(self.object_controller)
self.assertEquals(resp.status_int, 201)
@@ -2295,12 +2294,11 @@ class TestObjectController(unittest.TestCase):
# state.
start = time()
orig_timestamp = utils.Timestamp(start)
+ headers = {'X-Timestamp': orig_timestamp.internal,
+ 'Content-Type': 'application/octet-stream',
+ 'Content-Length': '4'}
req = Request.blank('/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
- headers={
- 'X-Timestamp': orig_timestamp.internal,
- 'Content-Type': 'application/octet-stream',
- 'Content-Length': '4',
- })
+ headers=headers)
req.body = 'test'
resp = req.get_response(self.object_controller)
self.assertEquals(resp.status_int, 201)
diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py
index 4df97040a..3171330ab 100644
--- a/test/unit/proxy/test_server.py
+++ b/test/unit/proxy/test_server.py
@@ -5763,11 +5763,10 @@ class TestObjectController(unittest.TestCase):
self.assertEquals(resp.status_int // 100, 5) # server error
# req supplies etag, object servers return 422 - mismatch
+ headers = {'Content-Length': '0',
+ 'ETag': '68b329da9893e34099c7d8ad5cb9c940'}
req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
- headers={
- 'Content-Length': '0',
- 'ETag': '68b329da9893e34099c7d8ad5cb9c940',
- })
+ headers=headers)
self.app.update_request(req)
set_http_connect(200, 422, 422, 503,
etags=['68b329da9893e34099c7d8ad5cb9c940',
@@ -8499,7 +8498,7 @@ class TestAccountController(unittest.TestCase):
self.assert_status_map(
controller.POST,
(404, 404, 404, 202, 202, 202, 201, 201, 201), 201)
- # account_info PUT account POST account
+ # account_info PUT account POST account
self.assert_status_map(
controller.POST,
(404, 404, 503, 201, 201, 503, 204, 204, 504), 204)