Remove log translations

Log messages are no longer being translated. This removes all use of the
_LE, _LI, and _LW translation markers to simplify logging and to avoid
confusion with new contributions. See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: I1c77ab511ad9aa87372c66af8cd49f9b2c38e085
This commit is contained in:
Tao Li 2017-03-21 13:27:59 +08:00
parent 1ecd4582ec
commit 179d341ecd
25 changed files with 87 additions and 146 deletions

View File

@ -17,22 +17,21 @@
from oslo_log import log
from meteos.api.middleware import auth
from meteos.i18n import _LW
LOG = log.getLogger(__name__)
class MeteosKeystoneContext(auth.MeteosKeystoneContext):
def __init__(self, application):
LOG.warning(_LW('meteos.api.auth:MeteosKeystoneContext is deprecated. '
LOG.warning('meteos.api.auth:MeteosKeystoneContext is deprecated. '
'Please use '
'meteos.api.middleware.auth:MeteosKeystoneContext '
'instead.'))
'instead.')
super(MeteosKeystoneContext, self).__init__(application)
def pipeline_factory(loader, global_conf, **local_conf):
LOG.warning(_LW('meteos.api.auth:pipeline_factory is deprecated. '
LOG.warning('meteos.api.auth:pipeline_factory is deprecated. '
'Please use meteos.api.middleware.auth:pipeline_factory '
'instead.'))
'instead.')
auth.pipeline_factory(loader, global_conf, **local_conf)

View File

@ -20,7 +20,6 @@ import webob.dec
import webob.exc
from meteos.api.openstack import wsgi
from meteos.i18n import _LE, _LI
from meteos import utils
from meteos import wsgi as base_wsgi
@ -41,7 +40,7 @@ class FaultWrapper(base_wsgi.Middleware):
status, webob.exc.HTTPInternalServerError)()
def _error(self, inner, req):
LOG.exception(_LE("Caught error: %s"), six.text_type(inner))
LOG.exception("Caught error: %s"), six.text_type(inner)
safe = getattr(inner, 'safe', False)
headers = getattr(inner, 'headers', None)
@ -50,7 +49,7 @@ class FaultWrapper(base_wsgi.Middleware):
status = 500
msg_dict = dict(url=req.url, status=status)
LOG.info(_LI("%(url)s returned with HTTP %(status)d"), msg_dict)
LOG.info("%(url)s returned with HTTP %(status)d", msg_dict)
outer = self.status_to_type(status)
if headers:
outer.headers = headers

View File

@ -21,7 +21,7 @@ WSGI middleware for OpenStack API controllers.
from oslo_log import log
import routes
from meteos.i18n import _, _LW
from meteos.i18n import _
from meteos import wsgi as base_wsgi
LOG = log.getLogger(__name__)
@ -72,9 +72,9 @@ class APIRouter(base_wsgi.Router):
class FaultWrapper(base_wsgi.Middleware):
def __init__(self, application):
LOG.warning(_LW('meteos.api.openstack:FaultWrapper is deprecated. '
'Please use '
'meteos.api.middleware.fault:FaultWrapper instead.'))
LOG.warning('meteos.api.openstack:FaultWrapper is deprecated. '
'Please use '
'meteos.api.middleware.fault:FaultWrapper instead.')
# Avoid circular imports from here.
from meteos.api.middleware import fault
super(FaultWrapper, self).__init__(fault.FaultWrapper(application))

View File

@ -17,13 +17,12 @@
from oslo_log import log
from meteos.api import urlmap
from meteos.i18n import _LW
LOG = log.getLogger(__name__)
def urlmap_factory(loader, global_conf, **local_conf):
LOG.warning(_LW('meteos.api.openstack.urlmap:urlmap_factory '
LOG.warning('meteos.api.openstack.urlmap:urlmap_factory '
'is deprecated. '
'Please use meteos.api.urlmap:urlmap_factory instead.'))
'Please use meteos.api.urlmap:urlmap_factory instead.')
urlmap.urlmap_factory(loader, global_conf, **local_conf)

View File

@ -29,7 +29,7 @@ from meteos.api.openstack import api_version_request as api_version
from meteos.api.openstack import versioned_method
from meteos.common import constants
from meteos import exception
from meteos.i18n import _, _LE, _LI
from meteos.i18n import _
from meteos import policy
from meteos import wsgi
@ -525,14 +525,14 @@ class ResourceExceptionHandler(object):
code=ex_value.code, explanation=six.text_type(ex_value)))
elif isinstance(ex_value, TypeError):
exc_info = (ex_type, ex_value, ex_traceback)
LOG.error(_LE('Exception handling resource: %s'),
LOG.error('Exception handling resource: %s',
ex_value, exc_info=exc_info)
raise Fault(webob.exc.HTTPBadRequest())
elif isinstance(ex_value, Fault):
LOG.info(_LI("Fault thrown: %s"), six.text_type(ex_value))
LOG.info("Fault thrown: %s", six.text_type(ex_value))
raise ex_value
elif isinstance(ex_value, webob.exc.HTTPException):
LOG.info(_LI("HTTP exception thrown: %s"), six.text_type(ex_value))
LOG.info("HTTP exception thrown: %s", six.text_type(ex_value))
raise Fault(ex_value)
# We didn't handle the exception
@ -733,7 +733,7 @@ class Resource(wsgi.Application):
def __call__(self, request):
"""WSGI method that controls (de)serialization and method dispatch."""
LOG.info(_LI("%(method)s %(url)s") % {"method": request.method,
LOG.info("%(method)s %(url)s" % {"method": request.method,
"url": request.url})
if self.support_api_request_version:
# Set the version of the API requested based on the header

View File

@ -25,9 +25,8 @@ from meteos.api import common
from meteos.api.openstack import wsgi
from meteos.api.views import datasets as dataset_views
from meteos.common import constants
from meteos import exception
from meteos.i18n import _, _LI
from meteos import engine
from meteos import exception
from meteos import utils
LOG = log.getLogger(__name__)
@ -58,7 +57,7 @@ class DatasetController(wsgi.Controller, wsgi.AdminActionsMixin):
"""Delete a dataset."""
context = req.environ['meteos.context']
LOG.info(_LI("Delete dataset with id: %s"), id, context=context)
LOG.info("Delete dataset with id: %s", id, context=context)
try:
self.engine_api.delete_dataset(context, id)

View File

@ -25,9 +25,8 @@ from meteos.api import common
from meteos.api.openstack import wsgi
from meteos.api.views import experiments as experiment_views
from meteos.common import constants
from meteos import exception
from meteos.i18n import _, _LI
from meteos import engine
from meteos import exception
from meteos import utils
LOG = log.getLogger(__name__)
@ -58,7 +57,7 @@ class ExperimentController(wsgi.Controller, wsgi.AdminActionsMixin):
"""Delete a experiment."""
context = req.environ['meteos.context']
LOG.info(_LI("Delete experiment with id: %s"), id, context=context)
LOG.info("Delete experiment with id: %s", id, context=context)
try:
self.engine_api.delete_experiment(context, id)

View File

@ -25,9 +25,8 @@ from meteos.api import common
from meteos.api.openstack import wsgi
from meteos.api.views import learnings as learning_views
from meteos.common import constants
from meteos import exception
from meteos.i18n import _, _LI
from meteos import engine
from meteos import exception
from meteos import utils
LOG = log.getLogger(__name__)
@ -58,7 +57,7 @@ class LearningController(wsgi.Controller, wsgi.AdminActionsMixin):
"""Delete a learning."""
context = req.environ['meteos.context']
LOG.info(_LI("Delete learning with id: %s"), id, context=context)
LOG.info("Delete learning with id: %s", id, context=context)
try:
self.engine_api.delete_learning(context, id)

View File

@ -25,9 +25,8 @@ from meteos.api import common
from meteos.api.openstack import wsgi
from meteos.api.views import model_evaluations as model_evaluation_views
from meteos.common import constants
from meteos import exception
from meteos.i18n import _, _LI
from meteos import engine
from meteos import exception
from meteos import utils
LOG = log.getLogger(__name__)
@ -59,7 +58,7 @@ class ModelEvaluationController(wsgi.Controller, wsgi.AdminActionsMixin):
"""Delete a model evaluation."""
context = req.environ['meteos.context']
LOG.info(_LI("Delete model evaluation with id: %s"), id, context=context)
LOG.info("Delete model evaluation with id: %s", id, context=context)
try:
self.engine_api.delete_model_evaluation(context, id)

View File

@ -25,9 +25,8 @@ from meteos.api import common
from meteos.api.openstack import wsgi
from meteos.api.views import models as model_views
from meteos.common import constants
from meteos import exception
from meteos.i18n import _, _LI
from meteos import engine
from meteos import exception
from meteos import utils
LOG = log.getLogger(__name__)
@ -160,7 +159,7 @@ class ModelController(wsgi.Controller, ModelMixin, wsgi.AdminActionsMixin):
"""Delete a model."""
context = req.environ['meteos.context']
LOG.info(_LI("Delete model with id: %s"), id, context=context)
LOG.info("Delete model with id: %s", id, context=context)
try:
self.engine_api.delete_model(context, id)

View File

@ -24,9 +24,8 @@ from webob import exc
from meteos.api import common
from meteos.api.openstack import wsgi
from meteos.api.views import templates as template_views
from meteos import exception
from meteos.i18n import _, _LI
from meteos import engine
from meteos import exception
LOG = log.getLogger(__name__)
@ -56,7 +55,7 @@ class TemplateController(wsgi.Controller, wsgi.AdminActionsMixin):
"""Delete a template."""
context = req.environ['meteos.context']
LOG.info(_LI("Delete template with id: %s"), id, context=context)
LOG.info("Delete template with id: %s", id, context=context)
try:
self.engine_api.delete_template(context, id)

View File

@ -26,7 +26,6 @@ from saharaclient import client as sahara_client
from meteos.common import client_auth
from meteos.common.config import core_opts
from meteos.db import base
from meteos.i18n import _
SAHARA_GROUP = 'sahara'

View File

@ -21,7 +21,7 @@ from oslo_config import cfg
from oslo_log import log
from meteos import exception
from meteos.i18n import _, _LW
from meteos.i18n import _
CONF = cfg.CONF
LOG = log.getLogger(__name__)

View File

@ -24,7 +24,7 @@ from oslo_log import log
from oslo_utils import timeutils
import six
from meteos.i18n import _, _LW
from meteos.i18n import _
from meteos import policy
LOG = log.getLogger(__name__)
@ -73,7 +73,7 @@ class RequestContext(context.RequestContext):
kwargs.pop('user_identity', None)
if kwargs:
LOG.warning(_LW('Arguments dropped when creating context: %s.'),
LOG.warning('Arguments dropped when creating context: %s.',
str(kwargs))
self.user_id = self.user
self.project_id = self.tenant

View File

@ -29,7 +29,6 @@ from oslo_log import log
from sqlalchemy import Boolean, Column, DateTime, Text
from sqlalchemy import Integer, MetaData, String, Table
from meteos.i18n import _LE
LOG = log.getLogger(__name__)
@ -238,7 +237,7 @@ def upgrade():
table.create()
except Exception:
LOG.info(repr(table))
LOG.exception(_LE('Exception while creating table.'))
LOG.exception('Exception while creating table.')
raise
if migrate_engine.name == "mysql":

View File

@ -37,7 +37,7 @@ from sqlalchemy.sql import func
from meteos.db.sqlalchemy import models
from meteos import exception
from meteos.i18n import _, _LE, _LW
from meteos.i18n import _
CONF = cfg.CONF

View File

@ -29,7 +29,7 @@ from meteos.common import constants
from meteos.db import base
from meteos.engine import rpcapi as engine_rpcapi
from meteos import exception
from meteos.i18n import _, _LE, _LI, _LW
from meteos.i18n import _
from meteos import policy
from meteos import utils
@ -171,7 +171,7 @@ class API(base.Base):
self.engine_rpcapi.create_experiment(context, result)
updates = {'status': constants.STATUS_CREATING}
LOG.info(_LI("Accepted creation of experiment %s."), result['id'])
LOG.info("Accepted creation of experiment %s.", result['id'])
self.db.experiment_update(context, result['id'], updates)
except Exception:
@ -278,7 +278,7 @@ class API(base.Base):
self.engine_rpcapi.create_dataset(context, result)
updates = {'status': constants.STATUS_CREATING}
LOG.info(_LI("Accepted parsing of dataset %s."), result['id'])
LOG.info("Accepted parsing of dataset %s.", result['id'])
self.db.dataset_update(context, result['id'], updates)
if result['test_dataset']:
@ -382,7 +382,7 @@ class API(base.Base):
self.engine_rpcapi.create_model(context, result)
updates = {'status': constants.STATUS_CREATING}
LOG.info(_LI("Accepted creation of model %s."), result['id'])
LOG.info("Accepted creation of model %s.", result['id'])
self.db.model_update(context, result['id'], updates)
except Exception:
with excutils.save_and_reraise_exception():
@ -419,7 +419,7 @@ class API(base.Base):
model['swift_username'] = swift_username
model['swift_password'] = swift_password
self.engine_rpcapi.create_model(context, model)
LOG.info(_LI("Accepted recreation of model %s."), id)
LOG.info("Accepted recreation of model %s.", id)
except Exception:
with excutils.save_and_reraise_exception():
@ -468,7 +468,7 @@ class API(base.Base):
self.engine_rpcapi.load_model(context, model)
updates = {'status': constants.STATUS_ACTIVATING}
LOG.info(_LI("Accepted load of model %s."), id)
LOG.info("Accepted load of model %s.", id)
self.db.model_update(context, id, updates)
except Exception:
with excutils.save_and_reraise_exception():
@ -492,7 +492,7 @@ class API(base.Base):
self.engine_rpcapi.unload_model(context, model)
updates = {'status': constants.STATUS_DEACTIVATING}
LOG.info(_LI("Accepted unload of model %s."), id)
LOG.info("Accepted unload of model %s.", id)
self.db.model_update(context, id, updates)
except Exception:
with excutils.save_and_reraise_exception():
@ -563,7 +563,7 @@ class API(base.Base):
result['id'],
updates)
LOG.info(_LI("Accepted creation of model evaluation %s."),
LOG.info("Accepted creation of model evaluation %s.",
result['id'])
except Exception:
with excutils.save_and_reraise_exception():
@ -650,7 +650,7 @@ class API(base.Base):
result['cluster_id'] = cluster_id
result['dataset_format'] = dataset_format
LOG.info(_LI("Status of Model %s."), status)
LOG.info("Status of Model %s.", status)
if status == constants.STATUS_AVAILABLE:
self.engine_rpcapi.create_learning(context, result)
@ -663,7 +663,7 @@ class API(base.Base):
self.engine_rpcapi.create_online_learning(context,
result)
LOG.info(_LI("Accepted creation of learning %s."), result['id'])
LOG.info("Accepted creation of learning %s.", result['id'])
except Exception:
with excutils.save_and_reraise_exception():
self.db.learning_delete(context, result['id'])

View File

@ -21,7 +21,6 @@ Drivers for learnings.
from oslo_config import cfg
from oslo_log import log
from meteos.i18n import _, _LE
LOG = log.getLogger(__name__)

View File

@ -30,9 +30,9 @@ from oslo_utils import excutils
from meteos import cluster
from meteos.common import constants as const
from meteos import context
from meteos import exception
from meteos.i18n import _, _LE, _LI, _LW
from meteos.engine import driver
from meteos import exception
from meteos.i18n import _
from meteos import utils
EXIT_CODE = '80577372-9349-463a-bbc3-1ca54f187cc9'
@ -128,7 +128,7 @@ class GenericLearningDriver(driver.LearningDriver):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Error running SSH command: %s"), command)
LOG.error("Error running SSH command: %s", command)
def _delete_hdfs_dir(self, context, cluster_id, dir_name):

View File

@ -28,7 +28,6 @@ from oslo_utils import timeutils
from meteos.common import constants
import meteos.engine.configuration
from meteos.i18n import _, _LE, _LI, _LW
from meteos import manager
LOG = log.getLogger(__name__)
@ -73,10 +72,10 @@ class LearningManager(manager.Manager):
if stderr:
status = constants.STATUS_ERROR
LOG.error(_LI("Fail to create %s."), id)
LOG.error("Fail to create %s.", id)
else:
status = constants.STATUS_AVAILABLE
LOG.info(_LI("%s created successfully."), id)
LOG.info("%s created successfully.", id)
updates = {
'status': status,
@ -113,14 +112,14 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("template %s failed on creation."),
LOG.error("template %s failed on creation.",
request_spec['id'])
self.db.template_update(
context, request_spec['id'],
{'status': constants.STATUS_ERROR}
)
LOG.info(_LI("template %s created successfully."),
LOG.info("template %s created successfully.",
request_spec['id'])
updates = response
@ -139,13 +138,13 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Template %s failed on deletion."), id)
LOG.error("Template %s failed on deletion.", id)
self.db.template_update(
context, id,
{'status': constants.STATUS_ERROR_DELETING}
)
LOG.info(_LI("Template %s deleted successfully."), id)
LOG.info("Template %s deleted successfully.", id)
self.db.template_delete(context, id)
def create_experiment(self, context, request_spec=None):
@ -166,14 +165,14 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Experiment %s failed on creation."),
LOG.error("Experiment %s failed on creation.",
request_spec['id'])
self.db.experiment_update(
context, request_spec['id'],
{'status': constants.STATUS_ERROR}
)
LOG.info(_LI("Experiment %s created successfully."),
LOG.info("Experiment %s created successfully.",
experiment['id'])
updates = {
'status': constants.STATUS_AVAILABLE,
@ -192,13 +191,13 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Experiment %s failed on deletion."), id)
LOG.error("Experiment %s failed on deletion.", id)
self.db.experiment_update(
context, id,
{'status': constants.STATUS_ERROR_DELETING}
)
LOG.info(_LI("Experiment %s deleted successfully."), id)
LOG.info("Experiment %s deleted successfully.", id)
self.db.experiment_delete(context, id)
def create_dataset(self, context, request_spec=None):
@ -217,7 +216,7 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Dataset %s failed on creation."),
LOG.error("Dataset %s failed on creation.",
request_spec['id'])
self.db.dataset_update(
context, request_spec['id'],
@ -244,13 +243,13 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Dataset %s failed on deletion."), id)
LOG.error("Dataset %s failed on deletion.", id)
self.db.dataset_update(
context, id,
{'status': constants.STATUS_ERROR_DELETING}
)
LOG.info(_LI("Dataset %s deleted successfully."), id)
LOG.info("Dataset %s deleted successfully.", id)
self.db.dataset_delete(context, id)
def create_model(self, context, request_spec=None):
@ -269,7 +268,7 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Model %s failed on creation."),
LOG.error("Model %s failed on creation.",
request_spec['id'])
self.db.model_update(
context, request_spec['id'],
@ -289,13 +288,13 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Model %s failed on deletion."), id)
LOG.error("Model %s failed on deletion.", id)
self.db.model_update(
context, id,
{'status': constants.STATUS_ERROR_DELETING}
)
LOG.info(_LI("Model %s deleted successfully."), id)
LOG.info("Model %s deleted successfully.", id)
if not recreate:
self.db.model_delete(context, id)
@ -314,7 +313,7 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Model %s failed on loading."),
LOG.error("Model %s failed on loading.",
request_spec['id'])
self.db.model_update(
context, request_spec['id'],
@ -338,7 +337,7 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Model %s failed on unloading."),
LOG.error("Model %s failed on unloading.",
request_spec['id'])
self.db.model_update(
context, request_spec['id'],
@ -366,7 +365,7 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Model Evaluation %s failed on creation."),
LOG.error("Model Evaluation %s failed on creation.",
model_evaluation_id)
self.db.model_evaluation_update(
context, model_evaluation_id,
@ -389,14 +388,14 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Model Evaluation %s failed on deletion."), id)
LOG.error("Model Evaluation %s failed on deletion.", id)
self.db.model_evaluation_update(
context, id,
{'status': constants.STATUS_ERROR_DELETING}
)
self.db.model_evaluation_delete(context, id)
LOG.info(_LI("Model Evaluation %s deleted successfully."), id)
LOG.info("Model Evaluation %s deleted successfully.", id)
def create_learning(self, context, request_spec=None):
"""Create a Learning."""
@ -415,7 +414,7 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Learning %s failed on creation."),
LOG.error("Learning %s failed on creation.",
learning_id)
self.db.learning_update(
context, learning_id,
@ -439,7 +438,7 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Learning %s failed on creation."),
LOG.error("Learning %s failed on creation.",
request_spec['id'])
self.db.learning_update(
context, request_spec['id'],
@ -458,11 +457,11 @@ class LearningManager(manager.Manager):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Learning %s failed on deletion."), id)
LOG.error("Learning %s failed on deletion.", id)
self.db.learning_update(
context, id,
{'status': constants.STATUS_ERROR_DELETING}
)
self.db.learning_delete(context, id)
LOG.info(_LI("Learning %s deleted successfully."), id)
LOG.info("Learning %s deleted successfully.", id)

View File

@ -30,7 +30,6 @@ import six
import webob.exc
from meteos.i18n import _
from meteos.i18n import _LE
LOG = log.getLogger(__name__)
@ -92,9 +91,9 @@ class MeteosException(Exception):
except Exception:
# kwargs doesn't match a variable in the message
# log the issue and the kwargs
LOG.exception(_LE('Exception in string format operation.'))
LOG.exception('Exception in string format operation.')
for name, value in kwargs.items():
LOG.error(_LE("%(name)s: %(value)s"), {
LOG.error("%(name)s: %(value)s", {
'name': name, 'value': value})
if CONF.fatal_exception_format_errors:
raise

View File

@ -38,14 +38,6 @@ UNDERSCORE_IMPORT_FILES = []
log_translation = re.compile(
r"(.)*LOG\.(audit|error|info|critical|exception)\(\s*('|\")")
log_translation_LC = re.compile(
r"(.)*LOG\.(critical)\(\s*(_\(|'|\")")
log_translation_LE = re.compile(
r"(.)*LOG\.(error|exception)\(\s*(_\(|'|\")")
log_translation_LI = re.compile(
r"(.)*LOG\.(info)\(\s*(_\(|'|\")")
log_translation_LW = re.compile(
r"(.)*LOG\.(warning|warn)\(\s*(_\(|'|\")")
translated_log = re.compile(
r"(.)*LOG\.(audit|error|info|warn|warning|critical|exception)"
"\(\s*_\(\s*('|\")")
@ -190,32 +182,6 @@ class CheckLoggingFormatArgs(BaseASTChecker):
return super(CheckLoggingFormatArgs, self).generic_visit(node)
def validate_log_translations(logical_line, physical_line, filename):
# Translations are not required in the test and tempest
# directories.
if ("meteos/tests" in filename or "meteos_tempest_tests" in filename or
"contrib/tempest" in filename):
return
if pep8.noqa(physical_line):
return
msg = "M327: LOG.critical messages require translations `_LC()`!"
if log_translation_LC.match(logical_line):
yield (0, msg)
msg = ("M328: LOG.error and LOG.exception messages require translations "
"`_LE()`!")
if log_translation_LE.match(logical_line):
yield (0, msg)
msg = "M329: LOG.info messages require translations `_LI()`!"
if log_translation_LI.match(logical_line):
yield (0, msg)
msg = "M330: LOG.warning messages require translations `_LW()`!"
if log_translation_LW.match(logical_line):
yield (0, msg)
msg = "M331: Log messages require translations!"
if log_translation.match(logical_line):
yield (0, msg)
def check_explicit_underscore_import(logical_line, filename):
"""Check for explicit import of the _ function
@ -347,7 +313,6 @@ def validate_assertIsNone(logical_line):
def factory(register):
register(validate_log_translations)
register(check_explicit_underscore_import)
register(no_translate_debug_logs)
register(CheckForStrUnicodeExc)

View File

@ -27,16 +27,6 @@ _translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
# The primary translation function using the well-known name "_"
_ = _translators.primary
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
def enable_lazy():
return oslo_i18n.enable_lazy()

View File

@ -31,7 +31,7 @@ from oslo_utils import importutils
from meteos import context
from meteos import db
from meteos import exception
from meteos.i18n import _, _LE, _LI, _LW
from meteos.i18n import _
from meteos import rpc
from meteos import version
from meteos import wsgi
@ -95,7 +95,7 @@ class Service(service.Service):
def start(self):
version_string = version.version_string()
LOG.info(_LI('Starting %(topic)s node (version %(version_string)s)'),
LOG.info('Starting %(topic)s node (version %(version_string)s)',
{'topic': self.topic, 'version_string': version_string})
self.model_disconnected = False
ctxt = context.get_admin_context()
@ -192,7 +192,7 @@ class Service(service.Service):
try:
db.service_destroy(context.get_admin_context(), self.service_id)
except exception.NotFound:
LOG.warning(_LW('Service killed that has no database entry.'))
LOG.warning('Service killed that has no database entry.')
def stop(self):
# Try to shut the connection down, but if we get any sort of
@ -243,13 +243,13 @@ class Service(service.Service):
# TODO(termie): make this pattern be more elegant.
if getattr(self, 'model_disconnected', False):
self.model_disconnected = False
LOG.error(_LE('Recovered model server connection!'))
LOG.error('Recovered model server connection!')
# TODO(vish): this should probably only catch connection errors
except Exception: # pylint: disable=W0702
if not getattr(self, 'model_disconnected', False):
self.model_disconnected = True
LOG.exception(_LE('model server went away'))
LOG.exception('model server went away')
class WSGIService(service.ServiceBase):
@ -274,8 +274,8 @@ class WSGIService(service.ServiceBase):
self.workers = getattr(CONF, '%s_workers' % name, None)
if self.workers is not None and self.workers < 1:
LOG.warning(
_LW("Value of config option %(name)s_workers must be integer "
"greater than 1. Input value ignored.") % {'name': name})
"Value of config option %(name)s_workers must be integer "
"greater than 1. Input value ignored." % {'name': name})
# Reset workers to default
self.workers = None
self.server = wsgi.Server(name,

View File

@ -41,7 +41,7 @@ import webob.exc
from meteos.common import config
from meteos import exception
from meteos.i18n import _, _LE, _LI
from meteos.i18n import _
socket_opts = [
cfg.IntOpt('backlog',
@ -183,7 +183,7 @@ class Server(service.ServiceBase):
{'host': host, 'port': port})
(self._host, self._port) = self._socket.getsockname()[0:2]
LOG.info(_LI("%(name)s listening on %(_host)s:%(_port)s"),
LOG.info("%(name)s listening on %(_host)s:%(_port)s",
{'name': self.name, '_host': self._host, '_port': self._port})
def start(self):
@ -231,8 +231,8 @@ class Server(service.ServiceBase):
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(
_LE("Failed to start %(name)s on %(_host)s:%(_port)s "
"with SSL support."),
"Failed to start %(name)s on %(_host)s:%(_port)s "
"with SSL support.",
{"name": self.name, "_host": self._host,
"_port": self._port}
)
@ -267,7 +267,7 @@ class Server(service.ServiceBase):
:returns: None
"""
LOG.info(_LI("Stopping WSGI server."))
LOG.info("Stopping WSGI server.")
if self._server is not None:
# Resize pool to stop new requests from being processed
self._pool.resize(0)
@ -286,7 +286,7 @@ class Server(service.ServiceBase):
self._pool.waitall()
self._server.wait()
except greenlet.GreenletExit:
LOG.info(_LI("WSGI server has stopped."))
LOG.info("WSGI server has stopped.")
def reset(self):
"""Reset server greenpool size to default.