Merge "Interpolate strings after calling _()"

This commit is contained in:
Jenkins 2013-08-12 21:38:45 +00:00 committed by Gerrit Code Review
commit 563c71c119
11 changed files with 34 additions and 34 deletions

View File

@ -119,7 +119,7 @@ class CacheFilter(wsgi.Middleware):
except exception.NotFound:
msg = _("Image cache contained image file for image '%s', "
"however the registry did not contain metadata for "
"that image!" % image_id)
"that image!") % image_id
LOG.error(msg)
self.cache.delete_cached_image(image_id)

View File

@ -748,7 +748,7 @@ class Controller(controller.BaseController):
raise HTTPForbidden(explanation=msg, request=req,
content_type="text/plain")
elif image['status'] == 'deleted':
msg = _("Image %s not found." % id)
msg = _("Image %s not found.") % id
LOG.debug(msg)
raise HTTPNotFound(explanation=msg, request=req,
content_type="text/plain")

View File

@ -173,8 +173,8 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
content_type='text/plain')
except exception.ImageSizeLimitExceeded as e:
msg = _("Denying attempt to upload image larger than %d bytes."
% CONF.image_size_cap)
msg = (_("Denying attempt to upload image larger than %d bytes.")
% CONF.image_size_cap)
LOG.info(msg)
safe_kill(req, image_id)
notifier.error('image.upload', msg)
@ -187,7 +187,7 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
# but something in the above function calls is affecting the
# exception context and we must explicitly re-raise the
# caught exception.
msg = _("Received HTTP error while uploading image %s" % image_id)
msg = _("Received HTTP error while uploading image %s") % image_id
notifier.error('image.upload', msg)
with excutils.save_and_reraise_exception():
LOG.exception(msg)
@ -202,7 +202,7 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
request=req)
except Exception as e:
msg = _("Failed to upload image %s" % image_id)
msg = _("Failed to upload image %s") % image_id
LOG.exception(msg)
safe_kill(req, image_id)
notifier.error('image.upload', msg)

View File

@ -115,7 +115,7 @@ class ImagesController(object):
image_repo.save(image)
except exception.NotFound:
msg = _("Failed to find image %(image_id)s to update" % locals())
msg = _("Failed to find image %(image_id)s to update") % locals()
LOG.info(msg)
raise webob.exc.HTTPNotFound(explanation=msg)
except exception.Forbidden as e:
@ -347,20 +347,20 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
We only accept a limited form of json pointers.
"""
if not pointer.startswith('/'):
msg = _('Pointer `%s` does not start with "/".' % pointer)
msg = _('Pointer `%s` does not start with "/".') % pointer
raise webob.exc.HTTPBadRequest(explanation=msg)
if re.search('/\s*?/', pointer[1:]):
msg = _('Pointer `%s` contains adjacent "/".' % pointer)
msg = _('Pointer `%s` contains adjacent "/".') % pointer
raise webob.exc.HTTPBadRequest(explanation=msg)
if len(pointer) > 1 and pointer.endswith('/'):
msg = _('Pointer `%s` end with "/".' % pointer)
msg = _('Pointer `%s` end with "/".') % pointer
raise webob.exc.HTTPBadRequest(explanation=msg)
if pointer[1:].strip() == '/':
msg = _('Pointer `%s` does not contains valid token.' % pointer)
msg = _('Pointer `%s` does not contains valid token.') % pointer
raise webob.exc.HTTPBadRequest(explanation=msg)
if re.search('~[^01]', pointer) or pointer.endswith('~'):
msg = _('Pointer `%s` contains "~" not part of'
' a recognized escape sequence.' % pointer)
' a recognized escape sequence.') % pointer
raise webob.exc.HTTPBadRequest(explanation=msg)
def _get_change_value(self, raw_change, op):
@ -476,14 +476,14 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
def _validate_sort_dir(self, sort_dir):
if sort_dir not in ['asc', 'desc']:
msg = _('Invalid sort direction: %s' % sort_dir)
msg = _('Invalid sort direction: %s') % sort_dir
raise webob.exc.HTTPBadRequest(explanation=msg)
return sort_dir
def _validate_member_status(self, member_status):
if member_status not in ['pending', 'accepted', 'rejected', 'all']:
msg = _('Invalid status: %s' % member_status)
msg = _('Invalid status: %s') % member_status
raise webob.exc.HTTPBadRequest(explanation=msg)
return member_status

View File

@ -325,7 +325,7 @@ def replication_dump(options, args):
client = imageservice(httplib.HTTPConnection(server, port),
options.mastertoken)
for image in client.get_images():
logging.info(_('Considering: %s' % image['id']))
logging.info(_('Considering: %s') % image['id'])
data_path = os.path.join(path, image['id'])
if not os.path.exists(data_path):

View File

@ -478,12 +478,12 @@ def validate_key_cert(key_file, cert_file):
cert = crypto.load_certificate(crypto.FILETYPE_PEM, cert_str)
except IOError, ioe:
raise RuntimeError(_("There is a problem with your %s "
"%s. Please verify it. Error: %s"
% (error_key_name, error_filename, ioe)))
"%s. Please verify it. Error: %s")
% (error_key_name, error_filename, ioe))
except crypto.Error, ce:
raise RuntimeError(_("There is a problem with your %s "
"%s. Please verify it. OpenSSL error: %s"
% (error_key_name, error_filename, ce)))
"%s. Please verify it. OpenSSL error: %s")
% (error_key_name, error_filename, ce))
try:
data = str(uuid.uuid4())
@ -494,8 +494,8 @@ def validate_key_cert(key_file, cert_file):
except crypto.Error, ce:
raise RuntimeError(_("There is a problem with your key pair. "
"Please verify that cert %s and key %s "
"belong together. OpenSSL error %s"
% (cert_file, key_file, ce)))
"belong together. OpenSSL error %s")
% (cert_file, key_file, ce))
def get_test_suite_socket():

View File

@ -246,7 +246,7 @@ class ImageCache(object):
if (image_checksum and
image_checksum != current_checksum.hexdigest()):
msg = _("Checksum verification failed. Aborted "
"caching of image '%s'." % image_id)
"caching of image '%s'.") % image_id
raise exception.GlanceException(msg)
except exception.GlanceException as e:

View File

@ -135,7 +135,7 @@ class QpidStrategy(strategy.Strategy):
except Exception:
details = dict(priority=priority, msg=msg)
LOG.exception(_('Notification error. Priority: %(priority)s '
'Message: %(msg)s' % details))
'Message: %(msg)s') % details)
raise
finally:
if self.connection and self.connection.opened():

View File

@ -321,7 +321,7 @@ def _check_meta_data(val, key=''):
elif t != unicode:
raise BackendException(_("The image metadata key %s has an invalid "
"type of %s. Only dict, list, and unicode "
"are supported." % (key, str(t))))
"are supported.") % (key, str(t)))
def store_add_to_backend(image_id, data, size, store):
@ -341,17 +341,17 @@ def store_add_to_backend(image_id, data, size, store):
(location, size, checksum, metadata) = store.add(image_id, data, size)
if metadata is not None:
if type(metadata) != dict:
msg = _("The storage driver %s returned invalid metadata %s"
"This must be a dictionary type" %
(str(store), str(metadata)))
msg = (_("The storage driver %s returned invalid metadata %s"
"This must be a dictionary type") %
(str(store), str(metadata)))
LOG.error(msg)
raise BackendException(msg)
try:
_check_meta_data(metadata)
except BackendException as e:
e_msg = _("A bad metadata structure was returned from the "
"%s storage driver: %s. %s." %
(str(store), str(metadata), str(e)))
e_msg = (_("A bad metadata structure was returned from the "
"%s storage driver: %s. %s.") %
(str(store), str(metadata), str(e)))
LOG.error(e_msg)
raise BackendException(e_msg)
return (location, size, checksum, metadata)

View File

@ -169,8 +169,8 @@ class Store(glance.store.base.Store):
except glance.store.BackendException as bee:
LOG.error(_('The JSON in the metadata file %s could not be used: '
'%s An empty dictionary will be returned '
'to the client.'
% (CONF.filesystem_store_metadata_file, str(bee))))
'to the client.')
% (CONF.filesystem_store_metadata_file, str(bee)))
return {}
except IOError as ioe:
LOG.error(_('The path for the metadata file %s could not be '
@ -181,7 +181,7 @@ class Store(glance.store.base.Store):
except Exception as ex:
LOG.exception(_('An error occured processing the storage systems '
'meta data file: %s. An empty dictionary will be '
'returned to the client.' % (str(ex))))
'returned to the client.') % str(ex))
return {}
def get(self, location):

View File

@ -317,7 +317,7 @@ class BaseStore(glance.store.base.Store):
def _delete_stale_chunks(self, connection, container, chunk_list):
for chunk in chunk_list:
LOG.debug(_("Deleting chunk %s" % chunk))
LOG.debug(_("Deleting chunk %s") % chunk)
try:
connection.delete_object(container, chunk)
except Exception: