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:
@@ -112,7 +112,7 @@ def notify(publisher_id, event_type, priority, payload):
|
|||||||
"""
|
"""
|
||||||
if priority not in log_levels:
|
if priority not in log_levels:
|
||||||
raise BadPriorityException(
|
raise BadPriorityException(
|
||||||
_('%s not in valid priorities' % priority))
|
_('%s not in valid priorities') % priority)
|
||||||
|
|
||||||
# Ensure everything is JSON serializable.
|
# Ensure everything is JSON serializable.
|
||||||
payload = utils.to_primitive(payload, convert_instances=True)
|
payload = utils.to_primitive(payload, convert_instances=True)
|
||||||
@@ -128,5 +128,5 @@ def notify(publisher_id, event_type, priority, payload):
|
|||||||
driver.notify(msg)
|
driver.notify(msg)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
LOG.exception(_("Problem '%(e)s' attempting to "
|
LOG.exception(_("Problem '%(e)s' attempting to "
|
||||||
"send to notification system. Payload=%(payload)s" %
|
"send to notification system. Payload=%(payload)s") %
|
||||||
locals()))
|
locals())
|
||||||
|
@@ -223,7 +223,7 @@ class Consumer(messaging.Consumer):
|
|||||||
# persistent failure occurs.
|
# persistent failure occurs.
|
||||||
except Exception, e: # pylint: disable=W0703
|
except Exception, e: # pylint: disable=W0703
|
||||||
if not self.failed_connection:
|
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
|
self.failed_connection = True
|
||||||
|
|
||||||
|
|
||||||
|
@@ -425,7 +425,7 @@ class Connection(object):
|
|||||||
for consumer in self.consumers:
|
for consumer in self.consumers:
|
||||||
consumer.reconnect(self.channel)
|
consumer.reconnect(self.channel)
|
||||||
LOG.info(_('Connected to AMQP server on '
|
LOG.info(_('Connected to AMQP server on '
|
||||||
'%(hostname)s:%(port)d' % self.params))
|
'%(hostname)s:%(port)d') % self.params)
|
||||||
|
|
||||||
def reconnect(self):
|
def reconnect(self):
|
||||||
"""Handles reconnecting and re-establishing queues.
|
"""Handles reconnecting and re-establishing queues.
|
||||||
|
@@ -337,12 +337,12 @@ class Connection(object):
|
|||||||
try:
|
try:
|
||||||
self.connection.open()
|
self.connection.open()
|
||||||
except qpid.messaging.exceptions.ConnectionError, e:
|
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)
|
time.sleep(FLAGS.qpid_reconnect_interval or 1)
|
||||||
else:
|
else:
|
||||||
break
|
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()
|
self.session = self.connection.session()
|
||||||
|
|
||||||
|
@@ -48,7 +48,7 @@ class DistributedScheduler(driver.Scheduler):
|
|||||||
|
|
||||||
NOTE: We're only focused on compute instances right now,
|
NOTE: We're only focused on compute instances right now,
|
||||||
so this method will always raise NoValidHost()."""
|
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)
|
raise exception.NoValidHost(reason=msg)
|
||||||
|
|
||||||
def schedule_run_instance(self, context, request_spec, *args, **kwargs):
|
def schedule_run_instance(self, context, request_spec, *args, **kwargs):
|
||||||
@@ -72,7 +72,7 @@ class DistributedScheduler(driver.Scheduler):
|
|||||||
*args, **kwargs)
|
*args, **kwargs)
|
||||||
|
|
||||||
if not weighted_hosts:
|
if not weighted_hosts:
|
||||||
raise exception.NoValidHost(reason=_(""))
|
raise exception.NoValidHost(reason="")
|
||||||
|
|
||||||
# NOTE(comstud): Make sure we do not pass this through. It
|
# NOTE(comstud): Make sure we do not pass this through. It
|
||||||
# contains an instance of RpcContext that cannot be serialized.
|
# contains an instance of RpcContext that cannot be serialized.
|
||||||
@@ -106,7 +106,7 @@ class DistributedScheduler(driver.Scheduler):
|
|||||||
hosts = self._schedule(context, 'compute', request_spec,
|
hosts = self._schedule(context, 'compute', request_spec,
|
||||||
*args, **kwargs)
|
*args, **kwargs)
|
||||||
if not hosts:
|
if not hosts:
|
||||||
raise exception.NoValidHost(reason=_(""))
|
raise exception.NoValidHost(reason="")
|
||||||
host = hosts.pop(0)
|
host = hosts.pop(0)
|
||||||
|
|
||||||
# NOTE(comstud): Make sure we do not pass this through. It
|
# NOTE(comstud): Make sure we do not pass this through. It
|
||||||
|
@@ -181,7 +181,7 @@ class VsaScheduler(simple.SimpleScheduler):
|
|||||||
selected_hosts,
|
selected_hosts,
|
||||||
unique)
|
unique)
|
||||||
if host is None:
|
if host is None:
|
||||||
raise exception.NoValidHost(reason=_(""))
|
raise exception.NoValidHost(reason="")
|
||||||
|
|
||||||
return (host, qos_cap)
|
return (host, qos_cap)
|
||||||
|
|
||||||
|
@@ -633,8 +633,8 @@ class XenAPIVMTestCase(test.TestCase):
|
|||||||
|
|
||||||
# mount point will be the last item of the command list
|
# mount point will be the last item of the command list
|
||||||
self._tmpdir = cmd[len(cmd) - 1]
|
self._tmpdir = cmd[len(cmd) - 1]
|
||||||
LOG.debug(_('Creating files in %s to simulate guest agent' %
|
LOG.debug(_('Creating files in %s to simulate guest agent') %
|
||||||
self._tmpdir))
|
self._tmpdir)
|
||||||
os.makedirs(os.path.join(self._tmpdir, 'usr', 'sbin'))
|
os.makedirs(os.path.join(self._tmpdir, 'usr', 'sbin'))
|
||||||
# Touch the file using open
|
# Touch the file using open
|
||||||
open(os.path.join(self._tmpdir, 'usr', 'sbin',
|
open(os.path.join(self._tmpdir, 'usr', 'sbin',
|
||||||
@@ -644,8 +644,8 @@ class XenAPIVMTestCase(test.TestCase):
|
|||||||
def _umount_handler(cmd, *ignore_args, **ignore_kwargs):
|
def _umount_handler(cmd, *ignore_args, **ignore_kwargs):
|
||||||
# Umount would normall make files in the m,ounted filesystem
|
# Umount would normall make files in the m,ounted filesystem
|
||||||
# disappear, so do that here
|
# disappear, so do that here
|
||||||
LOG.debug(_('Removing simulated guest agent files in %s' %
|
LOG.debug(_('Removing simulated guest agent files in %s') %
|
||||||
self._tmpdir))
|
self._tmpdir)
|
||||||
os.remove(os.path.join(self._tmpdir, 'usr', 'sbin',
|
os.remove(os.path.join(self._tmpdir, 'usr', 'sbin',
|
||||||
'xe-update-networking'))
|
'xe-update-networking'))
|
||||||
os.rmdir(os.path.join(self._tmpdir, 'usr', 'sbin'))
|
os.rmdir(os.path.join(self._tmpdir, 'usr', 'sbin'))
|
||||||
|
Reference in New Issue
Block a user