diff --git a/meteos/api/auth.py b/meteos/api/auth.py index 0503e3f..7bf9640 100644 --- a/meteos/api/auth.py +++ b/meteos/api/auth.py @@ -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) diff --git a/meteos/api/middleware/fault.py b/meteos/api/middleware/fault.py index 5a15bd8..ed70dd0 100644 --- a/meteos/api/middleware/fault.py +++ b/meteos/api/middleware/fault.py @@ -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 diff --git a/meteos/api/openstack/__init__.py b/meteos/api/openstack/__init__.py index d6fd537..f7015fc 100644 --- a/meteos/api/openstack/__init__.py +++ b/meteos/api/openstack/__init__.py @@ -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)) diff --git a/meteos/api/openstack/urlmap.py b/meteos/api/openstack/urlmap.py index 8ff1dfe..6b34b14 100644 --- a/meteos/api/openstack/urlmap.py +++ b/meteos/api/openstack/urlmap.py @@ -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) diff --git a/meteos/api/openstack/wsgi.py b/meteos/api/openstack/wsgi.py index 0d786fa..d00635e 100644 --- a/meteos/api/openstack/wsgi.py +++ b/meteos/api/openstack/wsgi.py @@ -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 diff --git a/meteos/api/v1/datasets.py b/meteos/api/v1/datasets.py index ba282a7..9ec9981 100644 --- a/meteos/api/v1/datasets.py +++ b/meteos/api/v1/datasets.py @@ -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) diff --git a/meteos/api/v1/experiments.py b/meteos/api/v1/experiments.py index c986366..088a4ab 100644 --- a/meteos/api/v1/experiments.py +++ b/meteos/api/v1/experiments.py @@ -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) diff --git a/meteos/api/v1/learnings.py b/meteos/api/v1/learnings.py index cdc1a0c..2c7aaee 100644 --- a/meteos/api/v1/learnings.py +++ b/meteos/api/v1/learnings.py @@ -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) diff --git a/meteos/api/v1/model_evaluations.py b/meteos/api/v1/model_evaluations.py index e89f43e..0b9ef35 100644 --- a/meteos/api/v1/model_evaluations.py +++ b/meteos/api/v1/model_evaluations.py @@ -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) diff --git a/meteos/api/v1/models.py b/meteos/api/v1/models.py index 01c2e4f..d72fa22 100644 --- a/meteos/api/v1/models.py +++ b/meteos/api/v1/models.py @@ -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) diff --git a/meteos/api/v1/templates.py b/meteos/api/v1/templates.py index be4ea77..5a5f71c 100644 --- a/meteos/api/v1/templates.py +++ b/meteos/api/v1/templates.py @@ -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) diff --git a/meteos/cluster/sahara.py b/meteos/cluster/sahara.py index d163296..23c69ea 100644 --- a/meteos/cluster/sahara.py +++ b/meteos/cluster/sahara.py @@ -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' diff --git a/meteos/common/client_auth.py b/meteos/common/client_auth.py index 2ed45c6..a8452a3 100644 --- a/meteos/common/client_auth.py +++ b/meteos/common/client_auth.py @@ -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__) diff --git a/meteos/context.py b/meteos/context.py index b2cfcb3..c34d7e8 100644 --- a/meteos/context.py +++ b/meteos/context.py @@ -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 diff --git a/meteos/db/migrations/alembic/versions/001_meteos_init.py b/meteos/db/migrations/alembic/versions/001_meteos_init.py index 7020738..682537c 100644 --- a/meteos/db/migrations/alembic/versions/001_meteos_init.py +++ b/meteos/db/migrations/alembic/versions/001_meteos_init.py @@ -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": diff --git a/meteos/db/sqlalchemy/api.py b/meteos/db/sqlalchemy/api.py index f302ace..ec72712 100644 --- a/meteos/db/sqlalchemy/api.py +++ b/meteos/db/sqlalchemy/api.py @@ -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 diff --git a/meteos/engine/api.py b/meteos/engine/api.py index 06ebf00..a27b3fe 100644 --- a/meteos/engine/api.py +++ b/meteos/engine/api.py @@ -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']) diff --git a/meteos/engine/driver.py b/meteos/engine/driver.py index 1078ab1..b95193b 100644 --- a/meteos/engine/driver.py +++ b/meteos/engine/driver.py @@ -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__) diff --git a/meteos/engine/drivers/generic.py b/meteos/engine/drivers/generic.py index d620b28..a7f7e5d 100644 --- a/meteos/engine/drivers/generic.py +++ b/meteos/engine/drivers/generic.py @@ -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): diff --git a/meteos/engine/manager.py b/meteos/engine/manager.py index 05ee532..2a70533 100644 --- a/meteos/engine/manager.py +++ b/meteos/engine/manager.py @@ -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) diff --git a/meteos/exception.py b/meteos/exception.py index 94fd4dc..efbc781 100644 --- a/meteos/exception.py +++ b/meteos/exception.py @@ -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 diff --git a/meteos/hacking/checks.py b/meteos/hacking/checks.py index dcb379d..066ede5 100644 --- a/meteos/hacking/checks.py +++ b/meteos/hacking/checks.py @@ -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) diff --git a/meteos/i18n.py b/meteos/i18n.py index 31372ae..b11da64 100644 --- a/meteos/i18n.py +++ b/meteos/i18n.py @@ -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() diff --git a/meteos/service.py b/meteos/service.py index daaa725..06880b3 100644 --- a/meteos/service.py +++ b/meteos/service.py @@ -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, diff --git a/meteos/wsgi.py b/meteos/wsgi.py index c7c9bc5..e75cf3a 100644 --- a/meteos/wsgi.py +++ b/meteos/wsgi.py @@ -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.