Only raw string literals should be used with _()

Fix a number of places where formatted strings were used with _() (causing
gettext to not match the string) or variables with _() (causing xgettext
to not extract a string)

Also, there's no value in internationalizing an empty string

Change-Id: Iac7dbe46eeaa8ddf03c2a357ecd52f69aa8678aa
This commit is contained in:
Johannes Erdfelt
2012-03-04 19:06:31 +00:00
parent 180f8010ab
commit ab68dbaacf
7 changed files with 15 additions and 15 deletions

View File

@@ -112,7 +112,7 @@ def notify(publisher_id, event_type, priority, payload):
"""
if priority not in log_levels:
raise BadPriorityException(
_('%s not in valid priorities' % priority))
_('%s not in valid priorities') % priority)
# Ensure everything is JSON serializable.
payload = utils.to_primitive(payload, convert_instances=True)
@@ -128,5 +128,5 @@ def notify(publisher_id, event_type, priority, payload):
driver.notify(msg)
except Exception, e:
LOG.exception(_("Problem '%(e)s' attempting to "
"send to notification system. Payload=%(payload)s" %
locals()))
"send to notification system. Payload=%(payload)s") %
locals())

View File

@@ -223,7 +223,7 @@ class Consumer(messaging.Consumer):
# persistent failure occurs.
except Exception, e: # pylint: disable=W0703
if not self.failed_connection:
LOG.exception(_('Failed to fetch message from queue: %s' % e))
LOG.exception(_('Failed to fetch message from queue: %s') % e)
self.failed_connection = True

View File

@@ -425,7 +425,7 @@ class Connection(object):
for consumer in self.consumers:
consumer.reconnect(self.channel)
LOG.info(_('Connected to AMQP server on '
'%(hostname)s:%(port)d' % self.params))
'%(hostname)s:%(port)d') % self.params)
def reconnect(self):
"""Handles reconnecting and re-establishing queues.

View File

@@ -337,12 +337,12 @@ class Connection(object):
try:
self.connection.open()
except qpid.messaging.exceptions.ConnectionError, e:
LOG.error(_('Unable to connect to AMQP server: %s ' % str(e)))
LOG.error(_('Unable to connect to AMQP server: %s ') % e)
time.sleep(FLAGS.qpid_reconnect_interval or 1)
else:
break
LOG.info(_('Connected to AMQP server on %s' % self.broker))
LOG.info(_('Connected to AMQP server on %s') % self.broker)
self.session = self.connection.session()

View File

@@ -48,7 +48,7 @@ class DistributedScheduler(driver.Scheduler):
NOTE: We're only focused on compute instances right now,
so this method will always raise NoValidHost()."""
msg = _("No host selection for %s defined." % topic)
msg = _("No host selection for %s defined.") % topic
raise exception.NoValidHost(reason=msg)
def schedule_run_instance(self, context, request_spec, *args, **kwargs):
@@ -72,7 +72,7 @@ class DistributedScheduler(driver.Scheduler):
*args, **kwargs)
if not weighted_hosts:
raise exception.NoValidHost(reason=_(""))
raise exception.NoValidHost(reason="")
# NOTE(comstud): Make sure we do not pass this through. It
# contains an instance of RpcContext that cannot be serialized.
@@ -106,7 +106,7 @@ class DistributedScheduler(driver.Scheduler):
hosts = self._schedule(context, 'compute', request_spec,
*args, **kwargs)
if not hosts:
raise exception.NoValidHost(reason=_(""))
raise exception.NoValidHost(reason="")
host = hosts.pop(0)
# NOTE(comstud): Make sure we do not pass this through. It

View File

@@ -181,7 +181,7 @@ class VsaScheduler(simple.SimpleScheduler):
selected_hosts,
unique)
if host is None:
raise exception.NoValidHost(reason=_(""))
raise exception.NoValidHost(reason="")
return (host, qos_cap)

View File

@@ -633,8 +633,8 @@ class XenAPIVMTestCase(test.TestCase):
# mount point will be the last item of the command list
self._tmpdir = cmd[len(cmd) - 1]
LOG.debug(_('Creating files in %s to simulate guest agent' %
self._tmpdir))
LOG.debug(_('Creating files in %s to simulate guest agent') %
self._tmpdir)
os.makedirs(os.path.join(self._tmpdir, 'usr', 'sbin'))
# Touch the file using open
open(os.path.join(self._tmpdir, 'usr', 'sbin',
@@ -644,8 +644,8 @@ class XenAPIVMTestCase(test.TestCase):
def _umount_handler(cmd, *ignore_args, **ignore_kwargs):
# Umount would normall make files in the m,ounted filesystem
# disappear, so do that here
LOG.debug(_('Removing simulated guest agent files in %s' %
self._tmpdir))
LOG.debug(_('Removing simulated guest agent files in %s') %
self._tmpdir)
os.remove(os.path.join(self._tmpdir, 'usr', 'sbin',
'xe-update-networking'))
os.rmdir(os.path.join(self._tmpdir, 'usr', 'sbin'))