Merge "Install global lazy _()"

This commit is contained in:
Jenkins 2014-03-24 15:33:50 +00:00 committed by Gerrit Code Review
commit f2019732bc
10 changed files with 57 additions and 57 deletions

View File

@ -36,9 +36,9 @@ class CPUPollster(plugin.ComputePollster):
instance_name = util.instance_name(instance) instance_name = util.instance_name(instance)
try: try:
cpu_info = manager.inspector.inspect_cpus(instance_name) cpu_info = manager.inspector.inspect_cpus(instance_name)
LOG.info(_("CPUTIME USAGE: %(instance)s %(time)d") % ( LOG.info(_("CPUTIME USAGE: %(instance)s %(time)d"),
{'instance': instance.__dict__, {'instance': instance.__dict__,
'time': cpu_info.time})) 'time': cpu_info.time})
cpu_num = {'cpu_number': cpu_info.number} cpu_num = {'cpu_number': cpu_info.number}
yield util.make_sample_from_instance( yield util.make_sample_from_instance(
instance, instance,

View File

@ -108,6 +108,7 @@ class DispatchedService(object):
def prepare_service(argv=None): def prepare_service(argv=None):
gettextutils.install('ceilometer', lazy=True) gettextutils.install('ceilometer', lazy=True)
gettextutils.enable_lazy()
rpc.set_defaults(control_exchange='ceilometer') rpc.set_defaults(control_exchange='ceilometer')
cfg.set_defaults(log.log_opts, cfg.set_defaults(log.log_opts,
default_log_levels=['amqplib=WARN', default_log_levels=['amqplib=WARN',

View File

@ -173,7 +173,7 @@ class Connection(object):
All timestamps must be naive utc datetime object. All timestamps must be naive utc datetime object.
""" """
raise NotImplementedError(_('Projects not implemented')) raise NotImplementedError('Projects not implemented')
@staticmethod @staticmethod
def clear_expired_metering_data(ttl): def clear_expired_metering_data(ttl):
@ -183,7 +183,7 @@ class Connection(object):
:param ttl: Number of seconds to keep records for. :param ttl: Number of seconds to keep records for.
""" """
raise NotImplementedError(_('Clearing samples not implemented')) raise NotImplementedError('Clearing samples not implemented')
@staticmethod @staticmethod
def get_users(source=None): def get_users(source=None):
@ -191,7 +191,7 @@ class Connection(object):
:param source: Optional source filter. :param source: Optional source filter.
""" """
raise NotImplementedError(_('Users not implemented')) raise NotImplementedError('Users not implemented')
@staticmethod @staticmethod
def get_projects(source=None): def get_projects(source=None):
@ -199,7 +199,7 @@ class Connection(object):
:param source: Optional source filter. :param source: Optional source filter.
""" """
raise NotImplementedError(_('Projects not implemented')) raise NotImplementedError('Projects not implemented')
@staticmethod @staticmethod
def get_resources(user=None, project=None, source=None, def get_resources(user=None, project=None, source=None,
@ -220,7 +220,7 @@ class Connection(object):
:param resource: Optional resource filter. :param resource: Optional resource filter.
:param pagination: Optional pagination query. :param pagination: Optional pagination query.
""" """
raise NotImplementedError(_('Resources not implemented')) raise NotImplementedError('Resources not implemented')
@staticmethod @staticmethod
def get_meters(user=None, project=None, resource=None, source=None, def get_meters(user=None, project=None, resource=None, source=None,
@ -235,7 +235,7 @@ class Connection(object):
:param metaquery: Optional dict with metadata to match on. :param metaquery: Optional dict with metadata to match on.
:param pagination: Optional pagination query. :param pagination: Optional pagination query.
""" """
raise NotImplementedError(_('Meters not implemented')) raise NotImplementedError('Meters not implemented')
@staticmethod @staticmethod
def get_samples(sample_filter, limit=None): def get_samples(sample_filter, limit=None):
@ -244,7 +244,7 @@ class Connection(object):
:param sample_filter: Filter. :param sample_filter: Filter.
:param limit: Maximum number of results to return. :param limit: Maximum number of results to return.
""" """
raise NotImplementedError(_('Samples not implemented')) raise NotImplementedError('Samples not implemented')
@staticmethod @staticmethod
def get_meter_statistics(sample_filter, period=None, groupby=None, def get_meter_statistics(sample_filter, period=None, groupby=None,
@ -253,13 +253,13 @@ class Connection(object):
The filter must have a meter value set. The filter must have a meter value set.
""" """
raise NotImplementedError(_('Statistics not implemented')) raise NotImplementedError('Statistics not implemented')
@staticmethod @staticmethod
def get_alarms(name=None, user=None, def get_alarms(name=None, user=None,
project=None, enabled=None, alarm_id=None, pagination=None): project=None, enabled=None, alarm_id=None, pagination=None):
"""Yields a lists of alarms that match filters.""" """Yields a lists of alarms that match filters."""
raise NotImplementedError(_('Alarms not implemented')) raise NotImplementedError('Alarms not implemented')
@staticmethod @staticmethod
def create_alarm(alarm): def create_alarm(alarm):
@ -267,17 +267,17 @@ class Connection(object):
:param alarm: The alarm to create. :param alarm: The alarm to create.
""" """
raise NotImplementedError(_('Alarms not implemented')) raise NotImplementedError('Alarms not implemented')
@staticmethod @staticmethod
def update_alarm(alarm): def update_alarm(alarm):
"""Update alarm.""" """Update alarm."""
raise NotImplementedError(_('Alarms not implemented')) raise NotImplementedError('Alarms not implemented')
@staticmethod @staticmethod
def delete_alarm(alarm_id): def delete_alarm(alarm_id):
"""Delete an alarm.""" """Delete an alarm."""
raise NotImplementedError(_('Alarms not implemented')) raise NotImplementedError('Alarms not implemented')
@staticmethod @staticmethod
def get_alarm_changes(alarm_id, on_behalf_of, def get_alarm_changes(alarm_id, on_behalf_of,
@ -307,12 +307,12 @@ class Connection(object):
:param end_timestamp: Optional modified timestamp end range :param end_timestamp: Optional modified timestamp end range
:param end_timestamp_op: Optional timestamp end range operation :param end_timestamp_op: Optional timestamp end range operation
""" """
raise NotImplementedError(_('Alarm history not implemented')) raise NotImplementedError('Alarm history not implemented')
@staticmethod @staticmethod
def record_alarm_change(alarm_change): def record_alarm_change(alarm_change):
"""Record alarm change event.""" """Record alarm change event."""
raise NotImplementedError(_('Alarm history not implemented')) raise NotImplementedError('Alarm history not implemented')
@staticmethod @staticmethod
def clear(): def clear():
@ -324,19 +324,19 @@ class Connection(object):
:param events: a list of model.Event objects. :param events: a list of model.Event objects.
""" """
raise NotImplementedError(_('Events not implemented.')) raise NotImplementedError('Events not implemented.')
@staticmethod @staticmethod
def get_events(event_filter): def get_events(event_filter):
"""Return an iterable of model.Event objects. """Return an iterable of model.Event objects.
""" """
raise NotImplementedError(_('Events not implemented.')) raise NotImplementedError('Events not implemented.')
@staticmethod @staticmethod
def get_event_types(): def get_event_types():
"""Return all event types as an iterable of strings. """Return all event types as an iterable of strings.
""" """
raise NotImplementedError(_('Events not implemented.')) raise NotImplementedError('Events not implemented.')
@staticmethod @staticmethod
def get_trait_types(event_type): def get_trait_types(event_type):
@ -346,7 +346,7 @@ class Connection(object):
:param event_type: the type of the Event :param event_type: the type of the Event
""" """
raise NotImplementedError(_('Events not implemented.')) raise NotImplementedError('Events not implemented.')
@staticmethod @staticmethod
def get_traits(event_type, trait_type=None): def get_traits(event_type, trait_type=None):
@ -357,7 +357,7 @@ class Connection(object):
:param trait_type: the name of the Trait to filter by :param trait_type: the name of the Trait to filter by
""" """
raise NotImplementedError(_('Events not implemented.')) raise NotImplementedError('Events not implemented.')
@staticmethod @staticmethod
def query_samples(filter_expr=None, orderby=None, limit=None): def query_samples(filter_expr=None, orderby=None, limit=None):
@ -368,8 +368,8 @@ class Connection(object):
:param limit: Maximum number of results to return. :param limit: Maximum number of results to return.
""" """
raise NotImplementedError(_('Complex query for samples \ raise NotImplementedError('Complex query for samples \
is not implemented.')) is not implemented.')
@staticmethod @staticmethod
def query_alarms(filter_expr=None, orderby=None, limit=None): def query_alarms(filter_expr=None, orderby=None, limit=None):
@ -380,8 +380,8 @@ class Connection(object):
:param limit: Maximum number of results to return. :param limit: Maximum number of results to return.
""" """
raise NotImplementedError(_('Complex query for alarms \ raise NotImplementedError('Complex query for alarms \
is not implemented.')) is not implemented.')
@staticmethod @staticmethod
def query_alarm_history(filter_expr=None, orderby=None, limit=None): def query_alarm_history(filter_expr=None, orderby=None, limit=None):
@ -392,11 +392,11 @@ class Connection(object):
:param limit: Maximum number of results to return. :param limit: Maximum number of results to return.
""" """
raise NotImplementedError(_('Complex query for alarms \ raise NotImplementedError('Complex query for alarms \
history is not implemented.')) history is not implemented.')
@staticmethod @staticmethod
def get_capabilities(): def get_capabilities():
"""Return an dictionary representing the capabilities of this driver. """Return an dictionary representing the capabilities of this driver.
""" """
raise NotImplementedError(_('Capabilities not implemented.')) raise NotImplementedError('Capabilities not implemented.')

View File

@ -302,7 +302,7 @@ class Connection(pymongo_base.Connection):
:param pagination: Optional pagination query. :param pagination: Optional pagination query.
""" """
if pagination: if pagination:
raise NotImplementedError(_('Pagination not implemented')) raise NotImplementedError('Pagination not implemented')
q = {} q = {}
if user is not None: if user is not None:
@ -364,8 +364,7 @@ class Connection(pymongo_base.Connection):
raise NotImplementedError("Unable to group by these fields") raise NotImplementedError("Unable to group by these fields")
if aggregate: if aggregate:
msg = _('Selectable aggregates not implemented') raise NotImplementedError('Selectable aggregates not implemented')
raise NotImplementedError(msg)
q = pymongo_base.make_query_from_filter(sample_filter) q = pymongo_base.make_query_from_filter(sample_filter)

View File

@ -228,7 +228,7 @@ class Connection(base.Connection):
project=None, enabled=None, alarm_id=None, pagination=None): project=None, enabled=None, alarm_id=None, pagination=None):
if pagination: if pagination:
raise NotImplementedError(_('Pagination not implemented')) raise NotImplementedError('Pagination not implemented')
alarm_table = self.conn.table(self.ALARM_TABLE) alarm_table = self.conn.table(self.ALARM_TABLE)
@ -373,7 +373,7 @@ class Connection(base.Connection):
:param pagination: Optional pagination query. :param pagination: Optional pagination query.
""" """
if pagination: if pagination:
raise NotImplementedError(_('Pagination not implemented')) raise NotImplementedError('Pagination not implemented')
meter_table = self.conn.table(self.METER_TABLE) meter_table = self.conn.table(self.METER_TABLE)
@ -427,7 +427,7 @@ class Connection(base.Connection):
""" """
if pagination: if pagination:
raise NotImplementedError(_('Pagination not implemented')) raise NotImplementedError('Pagination not implemented')
resource_table = self.conn.table(self.RESOURCE_TABLE) resource_table = self.conn.table(self.RESOURCE_TABLE)
q = make_query(metaquery=metaquery, user_id=user, project_id=project, q = make_query(metaquery=metaquery, user_id=user, project_id=project,
resource_id=resource, source=source) resource_id=resource, source=source)
@ -516,8 +516,7 @@ class Connection(base.Connection):
raise NotImplementedError("Group by not implemented.") raise NotImplementedError("Group by not implemented.")
if aggregate: if aggregate:
msg = _('Selectable aggregates not implemented') raise NotImplementedError('Selectable aggregates not implemented')
raise NotImplementedError(msg)
meter_table = self.conn.table(self.METER_TABLE) meter_table = self.conn.table(self.METER_TABLE)
q, start, stop = make_sample_query_from_filter(sample_filter) q, start, stop = make_sample_query_from_filter(sample_filter)

View File

@ -840,7 +840,7 @@ class Connection(pymongo_base.Connection):
:param pagination: Optional pagination query. :param pagination: Optional pagination query.
""" """
if pagination: if pagination:
raise NotImplementedError(_('Pagination not implemented')) raise NotImplementedError('Pagination not implemented')
query = {} query = {}
if user is not None: if user is not None:
@ -884,8 +884,8 @@ class Connection(pymongo_base.Connection):
params = dict(aggregate_param=a.param) params = dict(aggregate_param=a.param)
fragments += (fragment_map[a.func] % params) fragments += (fragment_map[a.func] % params)
else: else:
raise NotImplementedError(_('Selectable aggregate function %s' raise NotImplementedError('Selectable aggregate function %s'
' is not supported') % a.func) ' is not supported' % a.func)
return fragments return fragments

View File

@ -177,8 +177,8 @@ def apply_metaquery_filter(session, query, metaquery):
try: try:
_model = META_TYPE_MAP[type(v)] _model = META_TYPE_MAP[type(v)]
except KeyError: except KeyError:
raise NotImplementedError(_('Query on %(key)s is of %(value)s ' raise NotImplementedError('Query on %(key)s is of %(value)s '
'type and is not supported') % 'type and is not supported' %
{"key": k, "value": type(v)}) {"key": k, "value": type(v)})
else: else:
meta_q = session.query(_model).\ meta_q = session.query(_model).\
@ -201,7 +201,7 @@ def make_query_from_filter(session, query, sample_filter, require_meter=True):
if sample_filter.meter: if sample_filter.meter:
query = query.filter(models.Meter.name == sample_filter.meter) query = query.filter(models.Meter.name == sample_filter.meter)
elif require_meter: elif require_meter:
raise RuntimeError(_('Missing required meter specifier')) raise RuntimeError('Missing required meter specifier')
if sample_filter.source: if sample_filter.source:
query = query.filter(models.Sample.sources.any( query = query.filter(models.Sample.sources.any(
id=sample_filter.source)) id=sample_filter.source))
@ -466,7 +466,7 @@ class Connection(base.Connection):
# if they will be handled. We don't want extra wait or work for it to # if they will be handled. We don't want extra wait or work for it to
# just fail. # just fail.
if pagination: if pagination:
raise NotImplementedError(_('Pagination not implemented')) raise NotImplementedError('Pagination not implemented')
session = self._get_db_session() session = self._get_db_session()
@ -559,7 +559,7 @@ class Connection(base.Connection):
""" """
if pagination: if pagination:
raise NotImplementedError(_('Pagination not implemented')) raise NotImplementedError('Pagination not implemented')
session = self._get_db_session() session = self._get_db_session()
@ -711,8 +711,8 @@ class Connection(base.Connection):
compute = PARAMETERIZED_AGGREGATES['compute'][a.func] compute = PARAMETERIZED_AGGREGATES['compute'][a.func]
functions.append(compute(a.param)) functions.append(compute(a.param))
else: else:
raise NotImplementedError(_('Selectable aggregate function %s' raise NotImplementedError('Selectable aggregate function %s'
' is not supported') % a.func) ' is not supported' % a.func)
return functions return functions
@ -784,8 +784,8 @@ class Connection(base.Connection):
if groupby: if groupby:
for group in groupby: for group in groupby:
if group not in ['user_id', 'project_id', 'resource_id']: if group not in ['user_id', 'project_id', 'resource_id']:
raise NotImplementedError( raise NotImplementedError('Unable to group by '
_("Unable to group by these fields")) 'these fields')
if not period: if not period:
for res in self._make_stats_query(sample_filter, for res in self._make_stats_query(sample_filter,
@ -861,7 +861,7 @@ class Connection(base.Connection):
""" """
if pagination: if pagination:
raise NotImplementedError(_('Pagination not implemented')) raise NotImplementedError('Pagination not implemented')
session = self._get_db_session() session = self._get_db_session()
query = session.query(models.Alarm) query = session.query(models.Alarm)
@ -1343,8 +1343,8 @@ class QueryTransformer(object):
def _handle_metadata(self, op, field_name, value): def _handle_metadata(self, op, field_name, value):
if op == self.operators["in"]: if op == self.operators["in"]:
raise NotImplementedError( raise NotImplementedError('Metadata query with in '
_("Metadata query with in operator is not implemented")) 'operator is not implemented')
field_name = field_name[len('resource_metadata.'):] field_name = field_name[len('resource_metadata.'):]
meta_table = META_TYPE_MAP[type(value)] meta_table = META_TYPE_MAP[type(value)]

View File

@ -169,7 +169,7 @@ class Connection(base.Connection):
""" """
if pagination: if pagination:
raise NotImplementedError(_('Pagination not implemented')) raise NotImplementedError('Pagination not implemented')
q = {} q = {}
if user is not None: if user is not None:
@ -250,7 +250,7 @@ class Connection(base.Connection):
:param pagination: Optional pagination query. :param pagination: Optional pagination query.
""" """
if pagination: if pagination:
raise NotImplementedError(_('Pagination not implemented')) raise NotImplementedError('Pagination not implemented')
q = {} q = {}
if user is not None: if user is not None:

View File

@ -20,6 +20,7 @@
""" """
import functools import functools
import os.path import os.path
import six
from testtools import testcase from testtools import testcase
@ -59,10 +60,10 @@ def _skip_decorator(func):
try: try:
return func(*args, **kwargs) return func(*args, **kwargs)
except NotImplementedError as e: except NotImplementedError as e:
raise testcase.TestSkipped(str(e)) raise testcase.TestSkipped(six.text_type(e))
except Exception as e: except Exception as e:
if 'not implemented' in str(e): if 'not implemented' in six.text_type(e):
raise testcase.TestSkipped(str(e)) raise testcase.TestSkipped(six.text_type(e))
raise raise
return skip_if_not_implemented return skip_if_not_implemented

View File

@ -49,7 +49,7 @@ class TestBase(test_base.BaseTestCase):
try: try:
self.conn = storage.get_connection(self.CONF) self.conn = storage.get_connection(self.CONF)
except storage.StorageBadVersion as e: except storage.StorageBadVersion as e:
self.skipTest(str(e)) self.skipTest(six.text_type(e))
self.conn.upgrade() self.conn.upgrade()
self.useFixture(oslo_mock.Patch('ceilometer.storage.get_connection', self.useFixture(oslo_mock.Patch('ceilometer.storage.get_connection',