PEP8 fixes.

This commit is contained in:
yackob03 2013-10-08 11:29:42 -04:00
parent 427b745f2f
commit 6a038bb24e
7 changed files with 56 additions and 45 deletions

View file

@ -44,7 +44,7 @@ def require_completion(f):
def wrapper(namespace, repository, *args, **kwargs):
if store.exists(store.image_mark_path(namespace, repository,
kwargs['image_id'])):
abort(400) #'Image is being uploaded, retry later')
abort(400) # 'Image is being uploaded, retry later')
return f(namespace, repository, *args, **kwargs)
return wrapper
@ -85,7 +85,7 @@ def get_image_layer(namespace, repository, image_id, headers):
return Response(store.stream_read(store.image_layer_path(
namespace, repository, image_id)), headers=headers)
except IOError:
abort(404) #'Image not found', 404)
abort(404) # 'Image not found', 404)
abort(403)
@ -102,11 +102,11 @@ def put_image_layer(namespace, repository, image_id):
json_data = store.get_content(store.image_json_path(namespace, repository,
image_id))
except IOError:
abort(404) #'Image not found', 404)
abort(404) # 'Image not found', 404)
layer_path = store.image_layer_path(namespace, repository, image_id)
mark_path = store.image_mark_path(namespace, repository, image_id)
if store.exists(layer_path) and not store.exists(mark_path):
abort(409) #'Image already exists', 409)
abort(409) # 'Image already exists', 409)
input_stream = request.stream
if request.headers.get('transfer-encoding') == 'chunked':
# Careful, might work only with WSGI servers supporting chunked
@ -127,7 +127,7 @@ def put_image_layer(namespace, repository, image_id):
tmp.close()
except (IOError, checksums.TarError) as e:
logger.debug('put_image_layer: Error when computing tarsum '
'{0}'.format(e))
'{0}'.format(e))
try:
checksum = store.get_content(store.image_checksum_path(namespace,
repository,
@ -140,7 +140,7 @@ def put_image_layer(namespace, repository, image_id):
# We check if the checksums provided matches one the one we computed
if checksum not in csums:
logger.debug('put_image_layer: Wrong checksum')
abort(400) #'Checksum mismatch, ignoring the layer')
abort(400) # 'Checksum mismatch, ignoring the layer')
# Checksum is ok, we remove the marker
store.remove(mark_path)
return make_response('true', 200)
@ -156,14 +156,14 @@ def put_image_checksum(namespace, repository, image_id):
checksum = request.headers.get('X-Docker-Checksum')
if not checksum:
abort(400) #'Missing Image\'s checksum')
abort(400) # 'Missing Image\'s checksum')
if not session.get('checksum'):
abort(400) #'Checksum not found in Cookie')
abort(400) # 'Checksum not found in Cookie')
if not store.exists(store.image_json_path(namespace, repository, image_id)):
abort(404) #'Image not found', 404)
abort(404) # 'Image not found', 404)
mark_path = store.image_mark_path(namespace, repository, image_id)
if not store.exists(mark_path):
abort(409) #'Cannot set this image checksum', 409)
abort(409) # 'Cannot set this image checksum', 409)
err = store_checksum(namespace, repository, image_id, checksum)
if err:
abort(err)
@ -171,7 +171,7 @@ def put_image_checksum(namespace, repository, image_id):
logger.debug('session checksums: %s' % session.get('checksum', []))
logger.debug('client supplied checksum: %s' % checksum)
logger.debug('put_image_layer: Wrong checksum')
abort(400) #'Checksum mismatch')
abort(400) # 'Checksum mismatch')
# Checksum is ok, we remove the marker
store.remove(mark_path)
return make_response('true', 200)
@ -184,15 +184,15 @@ def put_image_checksum(namespace, repository, image_id):
@set_cache_headers
def get_image_json(namespace, repository, image_id, headers):
permission = ReadRepositoryPermission(namespace, repository)
if (not permission.can() and not
model.repository_is_public(namespace, repository)):
if not permission.can() and not model.repository_is_public(namespace,
repository):
abort(403)
try:
data = store.get_content(store.image_json_path(namespace, repository,
image_id))
except IOError:
abort(404) #'Image not found', 404)
abort(404) # 'Image not found', 404)
try:
size = store.get_size(store.image_layer_path(namespace, repository,
image_id))
@ -214,15 +214,15 @@ def get_image_json(namespace, repository, image_id, headers):
@set_cache_headers
def get_image_ancestry(namespace, repository, image_id, headers):
permission = ReadRepositoryPermission(namespace, repository)
if (not permission.can() and not
model.repository_is_public(namespace, repository)):
if not permission.can() and not model.repository_is_public(namespace,
repository):
abort(403)
try:
data = store.get_content(store.image_ancestry_path(namespace, repository,
image_id))
except IOError:
abort(404) #'Image not found', 404)
abort(404) # 'Image not found', 404)
response = make_response(json.dumps(json.loads(data)), 200)
response.headers.extend(headers)
return response
@ -265,9 +265,9 @@ def put_image_json(namespace, repository, image_id):
except json.JSONDecodeError:
pass
if not data or not isinstance(data, dict):
abort(400) #'Invalid JSON')
abort(400) # 'Invalid JSON')
if 'id' not in data:
abort(400) #'Missing key `id\' in JSON')
abort(400) # 'Missing key `id\' in JSON')
# Read the checksum
checksum = request.headers.get('X-Docker-Checksum')
if checksum:
@ -279,16 +279,16 @@ def put_image_json(namespace, repository, image_id):
# We cleanup any old checksum in case it's a retry after a fail
store.remove(store.image_checksum_path(namespace, repository, image_id))
if image_id != data['id']:
abort(400) #'JSON data contains invalid id')
abort(400) # 'JSON data contains invalid id')
parent_id = data.get('parent')
if parent_id and not store.exists(store.image_json_path(namespace,
repository,
data['parent'])):
abort(400) #'Image depends on a non existing parent')
abort(400) # 'Image depends on a non existing parent')
json_path = store.image_json_path(namespace, repository, image_id)
mark_path = store.image_mark_path(namespace, repository, image_id)
if store.exists(json_path) and not store.exists(mark_path):
abort(409) #'Image already exists', 409)
abort(409) # 'Image already exists', 409)
# If we reach that point, it means that this is a new image or a retry
# on a failed push
# save the metadata
@ -311,4 +311,4 @@ def delete_repository_storage(namespace, repository):
repository_path = store.repository_namespace_path(namespace, repository)
logger.debug('Recursively deleting path: %s' % repository_path)
store.remove(repository_path)
store.remove(repository_path)