From 3622b36bba918d51fffba8b828d52a649c7dc582 Mon Sep 17 00:00:00 2001 From: Nikhil Komawar Date: Wed, 3 Sep 2014 19:52:55 -0400 Subject: [PATCH] Fixes logging in image_import's main module Some of the logs were not translated. This patch fixes those and some other logs. Change-Id: I153b3aef13bdc4a3c0ef477d3bccd93c5c1887ff --- glance/common/scripts/image_import/main.py | 14 +++++++------- glance/common/scripts/utils.py | 15 +++++++-------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/glance/common/scripts/image_import/main.py b/glance/common/scripts/image_import/main.py index 24dd52bb8c..1caab372b6 100644 --- a/glance/common/scripts/image_import/main.py +++ b/glance/common/scripts/image_import/main.py @@ -99,10 +99,10 @@ def import_image(image_repo, image_factory, task_input, task_id, uri): new_image.virtual_size = original_image.virtual_size new_image.checksum = original_image.checksum else: - msg = _LE("The Image %(image_id)s object being created by this task " - "%(task_id)s, is no longer in valid status for further " - "processing." % {"image_id": new_image.image_id, - "task_id": task_id}) + msg = _("The Image %(image_id)s object being created by this task " + "%(task_id)s, is no longer in valid status for further " + "processing.") % {"image_id": new_image.image_id, + "task_id": task_id} raise exception.Conflict(msg) image_repo.save(new_image) @@ -120,9 +120,9 @@ def create_image(image_repo, image_factory, image_properties, task_id): try: properties[key] = image_properties.pop(key) except KeyError: - msg = _("Task ID %(task_id)s: Ignoring property %(k)s for setting " - "base properties while creating " - "Image.") % {'task_id': task_id, 'k': key} + msg = ("Task ID %(task_id)s: Ignoring property %(k)s for setting " + "base properties while creating " + "Image.") % {'task_id': task_id, 'k': key} LOG.debug(msg) # NOTE: get the rest of the properties and pass them as diff --git a/glance/common/scripts/utils.py b/glance/common/scripts/utils.py index ab1611f75a..6cd6df840e 100644 --- a/glance/common/scripts/utils.py +++ b/glance/common/scripts/utils.py @@ -94,8 +94,8 @@ def validate_location_uri(location): # NOTE: file type uri is being avoided for security reasons, # see LP bug #942118. elif location.startswith("file:///"): - msg = ("File based imports are not allowed. Please use a non-local " - "source of image data.") + msg = _("File based imports are not allowed. Please use a non-local " + "source of image data.") # NOTE: raise Exception and let the encompassing block save # the error msg in the task.message. raise StandardError(msg) @@ -103,16 +103,15 @@ def validate_location_uri(location): else: #TODO(nikhil): add other supported uris supported = ['http', ] - msg = ("The given uri is not valid. Please specify a " - "valid uri from the following list of supported uri " - "%(supported)s" % {'supported': supported}) + msg = _("The given uri is not valid. Please specify a " + "valid uri from the following list of supported uri " + "%(supported)s") % {'supported': supported} raise urllib2.URLError(msg) def get_image_data_iter(uri): - """ - The scripts are expected to support only over non-local locations of data. - Note the absence of file:// for security reasons, see LP bug #942118. + """The scripts are expected to support only over non-local locations of + data. Note the absence of file:// for security reasons, see LP bug #942118. If the above constraint is violated, task should fail. """ # NOTE: Current script supports http location. Other locations