diff --git a/glance/common/property_utils.py b/glance/common/property_utils.py index d0915eb0d6..50efdcc09c 100644 --- a/glance/common/property_utils.py +++ b/glance/common/property_utils.py @@ -80,17 +80,17 @@ class PropertyRules(object): conf_file = CONF.find_file(CONF.property_protection_file) CONFIG.read(conf_file) except Exception as e: - msg = (_("Couldn't find property protection file %(file)s: " - "%(error)s.") % {'file': CONF.property_protection_file, - 'error': e}) + msg = (_LE("Couldn't find property protection file %(file)s: " + "%(error)s.") % {'file': CONF.property_protection_file, + 'error': e}) LOG.error(msg) raise InvalidPropProtectConf() if self.prop_prot_rule_format not in ['policies', 'roles']: - msg = _("Invalid value '%s' for " - "'property_protection_rule_format'. " - "The permitted values are " - "'roles' and 'policies'") % self.prop_prot_rule_format + msg = _LE("Invalid value '%s' for " + "'property_protection_rule_format'. " + "The permitted values are " + "'roles' and 'policies'") % self.prop_prot_rule_format LOG.error(msg) raise InvalidPropProtectConf() @@ -119,7 +119,7 @@ class PropertyRules(object): permissions = [permission.strip() for permission in permissions.split(',')] if '@' in permissions and '!' in permissions: - msg = (_( + msg = (_LE( "Malformed property protection rule in " "[%(prop)s] %(op)s=%(perm)s: '@' and '!' " "are mutually exclusive") % @@ -144,9 +144,9 @@ class PropertyRules(object): try: return re.compile(rule) except Exception as e: - msg = (_("Encountered a malformed property protection rule" - " %(rule)s: %(error)s.") % {'rule': rule, - 'error': e}) + msg = (_LE("Encountered a malformed property protection rule" + " %(rule)s: %(error)s.") % {'rule': rule, + 'error': e}) LOG.error(msg) raise InvalidPropProtectConf() diff --git a/glance/common/rpc.py b/glance/common/rpc.py index 1eea5705f4..e990507b69 100644 --- a/glance/common/rpc.py +++ b/glance/common/rpc.py @@ -34,6 +34,7 @@ import glance.openstack.common.log as logging LOG = logging.getLogger(__name__) _ = i18n._ +_LE = i18n._LE rpc_opts = [ @@ -182,7 +183,7 @@ class Controller(object): raise cls, val = e.__class__, utils.exception_to_str(e) - msg = (_("RPC Call Error: %(val)s\n%(tb)s") % + msg = (_LE("RPC Call Error: %(val)s\n%(tb)s") % dict(val=val, tb=traceback.format_exc())) LOG.error(msg) diff --git a/glance/common/swift_store_utils.py b/glance/common/swift_store_utils.py index d46e754124..dd1cd3d7aa 100644 --- a/glance/common/swift_store_utils.py +++ b/glance/common/swift_store_utils.py @@ -84,7 +84,7 @@ class SwiftParams(object): conf_file = CONF.find_file(CONF.swift_store_config_file) CONFIG.read(conf_file) except Exception as e: - msg = (_("swift config file %(conf_file)s:%(exc)s not found") % + msg = (_LE("swift config file %(conf_file)s:%(exc)s not found") % {'conf_file': CONF.swift_store_config_file, 'exc': e}) LOG.error(msg) raise exception.InvalidSwiftStoreConfiguration() diff --git a/glance/common/utils.py b/glance/common/utils.py index c715f4d18c..9a1b2c4fea 100644 --- a/glance/common/utils.py +++ b/glance/common/utils.py @@ -53,6 +53,7 @@ CONF = cfg.CONF LOG = logging.getLogger(__name__) _ = i18n._ +_LE = i18n._LE FEATURE_BLACKLIST = ['content-length', 'content-type', 'x-image-meta-size'] @@ -111,7 +112,7 @@ def cooperative_iter(iter): yield chunk except Exception as err: with excutils.save_and_reraise_exception(): - msg = _("Error: cooperative_iter exception %s") % err + msg = _LE("Error: cooperative_iter exception %s") % err LOG.error(msg) @@ -510,10 +511,10 @@ def mutating(func): def setup_remote_pydev_debug(host, port): - error_msg = _('Error setting up the debug environment. Verify that the' - ' option pydev_worker_debug_host is pointing to a valid ' - 'hostname or IP on which a pydev server is listening on' - ' the port indicated by pydev_worker_debug_port.') + error_msg = _LE('Error setting up the debug environment. Verify that the' + ' option pydev_worker_debug_host is pointing to a valid ' + 'hostname or IP on which a pydev server is listening on' + ' the port indicated by pydev_worker_debug_port.') try: try: diff --git a/glance/domain/__init__.py b/glance/domain/__init__.py index 9d9790087e..0056bdaf83 100644 --- a/glance/domain/__init__.py +++ b/glance/domain/__init__.py @@ -30,6 +30,7 @@ import glance.openstack.common.log as logging _ = i18n._ _LE = i18n._LE +_LI = i18n._LI _LW = i18n._LW LOG = logging.getLogger(__name__) CONF = cfg.CONF @@ -373,15 +374,15 @@ class Task(object): def _set_task_status(self, new_status): if self._validate_task_status_transition(self.status, new_status): self._status = new_status - log_msg = (_("Task [%(task_id)s] status changing from " - "%(cur_status)s to %(new_status)s") % + log_msg = (_LI("Task [%(task_id)s] status changing from " + "%(cur_status)s to %(new_status)s") % {'task_id': self.task_id, 'cur_status': self.status, 'new_status': new_status}) LOG.info(log_msg) self._status = new_status else: - log_msg = (_("Task [%(task_id)s] status failed to change from " - "%(cur_status)s to %(new_status)s") % + log_msg = (_LE("Task [%(task_id)s] status failed to change from " + "%(cur_status)s to %(new_status)s") % {'task_id': self.task_id, 'cur_status': self.status, 'new_status': new_status}) LOG.error(log_msg) diff --git a/glance/image_cache/drivers/xattr.py b/glance/image_cache/drivers/xattr.py index 82855107db..6f49b63ed0 100644 --- a/glance/image_cache/drivers/xattr.py +++ b/glance/image_cache/drivers/xattr.py @@ -69,6 +69,7 @@ from glance.image_cache.drivers import base import glance.openstack.common.log as logging LOG = logging.getLogger(__name__) +_ = i18n._ _LE = i18n._LE _LI = i18n._LI _LW = i18n._LW @@ -106,11 +107,11 @@ class Driver(base.Driver): set_xattr(fake_image_filepath, 'hits', '1') except IOError as e: if e.errno == errno.EOPNOTSUPP: - msg = (_LE("The device housing the image cache directory " - "%(image_cache_dir)s does not support xattr. It is" - " likely you need to edit your fstab and add the " - "user_xattr option to the appropriate line for the" - " device housing the cache directory.") % + msg = (_("The device housing the image cache directory " + "%(image_cache_dir)s does not support xattr. It is" + " likely you need to edit your fstab and add the " + "user_xattr option to the appropriate line for the" + " device housing the cache directory.") % {'image_cache_dir': image_cache_dir}) LOG.error(msg) raise exception.BadDriverConfiguration(driver_name="xattr", diff --git a/glance/notifier.py b/glance/notifier.py index dc59e95764..5e162cdf8d 100644 --- a/glance/notifier.py +++ b/glance/notifier.py @@ -31,6 +31,7 @@ from glance import i18n import glance.openstack.common.log as logging _ = i18n._ +_LE = i18n._LE notifier_opts = [ cfg.StrOpt('default_publisher_id', default="image.localhost", @@ -357,8 +358,8 @@ class ImageProxy(NotificationProxy, domain_proxy.Image): _send_notification(notify, 'image.send', self._format_image_send(sent)) except Exception as err: - msg = (_("An error occurred during image.send" - " notification: %(err)s") % {'err': err}) + msg = (_LE("An error occurred during image.send" + " notification: %(err)s") % {'err': err}) LOG.error(msg) def get_data(self, offset=0, chunk_size=None): diff --git a/tools/migrate_image_owners.py b/tools/migrate_image_owners.py index 80df06ccf5..d05a29a05e 100644 --- a/tools/migrate_image_owners.py +++ b/tools/migrate_image_owners.py @@ -26,6 +26,7 @@ import glance.registry.context _ = i18n._ _LC = i18n._LC +_LE = i18n._LE _LI = i18n._LI LOG = logging.getLogger(__name__) @@ -55,13 +56,16 @@ def build_image_owner_map(owner_map, db, context): try: owner_id = owner_map[owner_name] except KeyError: - msg = 'Image %s owner %s was not found. Skipping.' - LOG.error(msg % (image_id, owner_name)) + msg = (_LE('Image "%(image)s" owner "%(owner)s" was not found. ' + 'Skipping.'), + {'image': image_id, 'owner': owner_name}) + LOG.error(msg) continue image_owner_map[image_id] = owner_id - msg = 'Image %s owner %s -> %s' % (image_id, owner_name, owner_id) + msg = (_LI('Image "%(image)s" owner "%(owner)s" -> "%(owner_id)s"'), + {'image': image_id, 'owner': owner_name, 'owner_id': owner_id}) LOG.info(msg) return image_owner_map