From 736ed310ac924641b12d9440c5d38a19cbaf974e Mon Sep 17 00:00:00 2001 From: libing Date: Wed, 22 Mar 2017 09:53:02 +0800 Subject: [PATCH] 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: I4c8c83315897c7e64b05402c233b0fa67eb03a6e --- novaclient/api_versions.py | 8 +++--- novaclient/client.py | 46 +++++++++++++++---------------- novaclient/i18n.py | 10 ------- novaclient/v2/client.py | 36 ++++++++++++------------ novaclient/v2/contrib/__init__.py | 16 +++++------ novaclient/v2/migrations.py | 8 +++--- novaclient/v2/shell.py | 3 +- 7 files changed, 58 insertions(+), 69 deletions(-) diff --git a/novaclient/api_versions.py b/novaclient/api_versions.py index 65e510b5c..796beadc4 100644 --- a/novaclient/api_versions.py +++ b/novaclient/api_versions.py @@ -23,7 +23,7 @@ from oslo_utils import strutils import novaclient from novaclient import exceptions -from novaclient.i18n import _, _LW +from novaclient.i18n import _ LOG = logging.getLogger(__name__) if not LOG.handlers: @@ -234,8 +234,8 @@ def get_api_version(version_string): version_string = str(version_string) if version_string in DEPRECATED_VERSIONS: LOG.warning( - _LW("Version %(deprecated_version)s is deprecated, using " - "alternative version %(alternative)s instead."), + _("Version %(deprecated_version)s is deprecated, using " + "alternative version %(alternative)s instead."), {"deprecated_version": version_string, "alternative": DEPRECATED_VERSIONS[version_string]}) version_string = DEPRECATED_VERSIONS[version_string] @@ -421,7 +421,7 @@ def wraps(start_version, end_version=None): def _warn_missing_microversion_header(header_name): """Log a warning about missing microversion response header.""" - LOG.warning(_LW( + LOG.warning(_( "Your request was processed by a Nova API which does not support " "microversions (%s header is missing from response). " "Warning: Response may be incorrect."), header_name) diff --git a/novaclient/client.py b/novaclient/client.py index 4d3f0f387..09ca56474 100644 --- a/novaclient/client.py +++ b/novaclient/client.py @@ -36,7 +36,7 @@ osprofiler_web = importutils.try_import("osprofiler.web") from novaclient import api_versions from novaclient import exceptions from novaclient import extension as ext -from novaclient.i18n import _, _LW +from novaclient.i18n import _ from novaclient import utils @@ -90,16 +90,16 @@ class SessionClient(adapter.LegacyJsonAdapter): @property def management_url(self): self.logger.warning( - _LW("Property `management_url` is deprecated for SessionClient. " - "Use `endpoint_override` instead.")) + _("Property `management_url` is deprecated for SessionClient. " + "Use `endpoint_override` instead.")) return self.endpoint_override @management_url.setter def management_url(self, value): self.logger.warning( - _LW("Property `management_url` is deprecated for SessionClient. " - "It should be set via `endpoint_override` variable while class" - " initialization.")) + _("Property `management_url` is deprecated for SessionClient. " + "It should be set via `endpoint_override` variable while class" + " initialization.")) self.endpoint_override = value @@ -177,11 +177,11 @@ def discover_extensions(*args, **kwargs): """ # TODO(mriedem): Remove support for 'only_contrib' in Queens. if 'only_contrib' in kwargs and kwargs['only_contrib']: - warnings.warn(_LW('Discovering extensions only by contrib path is no ' - 'longer supported since all contrib extensions ' - 'have either been made required or removed. The ' - 'only_contrib argument is deprecated and will be ' - 'removed in a future release.')) + warnings.warn(_('Discovering extensions only by contrib path is no ' + 'longer supported since all contrib extensions ' + 'have either been made required or removed. The ' + 'only_contrib argument is deprecated and will be ' + 'removed in a future release.')) return [] chain = itertools.chain(_discover_via_python_path(), _discover_via_entry_points()) @@ -223,8 +223,8 @@ def _get_client_class_and_version(version): def get_client_class(version): """Returns Client class based on given version.""" - warnings.warn(_LW("'get_client_class' is deprecated. " - "Please use `novaclient.client.Client` instead.")) + warnings.warn(_("'get_client_class' is deprecated. " + "Please use `novaclient.client.Client` instead.")) _api_version, client_class = _get_client_class_and_version(version) return client_class @@ -238,25 +238,25 @@ def _check_arguments(kwargs, release, deprecated_name, right_name=None): if deprecated_name in kwargs: if right_name: if right_name in kwargs: - msg = _LW("The '%(old)s' argument is deprecated in " - "%(release)s and its use may result in errors " - "in future releases. As '%(new)s' is provided, " - "the '%(old)s' argument will be ignored.") % { + msg = _("The '%(old)s' argument is deprecated in " + "%(release)s and its use may result in errors " + "in future releases. As '%(new)s' is provided, " + "the '%(old)s' argument will be ignored.") % { "old": deprecated_name, "release": release, "new": right_name} kwargs.pop(deprecated_name) else: - msg = _LW("The '%(old)s' argument is deprecated in " - "%(release)s and its use may result in errors in " - "future releases. Use '%(right)s' instead.") % { + msg = _("The '%(old)s' argument is deprecated in " + "%(release)s and its use may result in errors in " + "future releases. Use '%(right)s' instead.") % { "old": deprecated_name, "release": release, "right": right_name} kwargs[right_name] = kwargs.pop(deprecated_name) else: - msg = _LW("The '%(old)s' argument is deprecated in %(release)s " - "and its use may result in errors in future " - "releases.") % { + msg = _("The '%(old)s' argument is deprecated in %(release)s " + "and its use may result in errors in future " + "releases.") % { "old": deprecated_name, "release": release} # just ignore it kwargs.pop(deprecated_name) diff --git a/novaclient/i18n.py b/novaclient/i18n.py index 6a17312d6..ccf8e583a 100644 --- a/novaclient/i18n.py +++ b/novaclient/i18n.py @@ -23,13 +23,3 @@ _translators = oslo_i18n.TranslatorFactory(domain='novaclient') # 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 diff --git a/novaclient/v2/client.py b/novaclient/v2/client.py index 2ffa7bd93..4b504853d 100644 --- a/novaclient/v2/client.py +++ b/novaclient/v2/client.py @@ -19,7 +19,7 @@ from keystoneauth1.exceptions import catalog as key_ex from novaclient import client from novaclient import exceptions -from novaclient.i18n import _LE, _LW +from novaclient.i18n import _ from novaclient.v2 import agents from novaclient.v2 import aggregates from novaclient.v2 import assisted_volume_snapshots @@ -127,11 +127,11 @@ class Client(object): """ if direct_use: raise exceptions.Forbidden( - 403, _LE("'novaclient.v2.client.Client' is not designed to be " - "initialized directly. It is inner class of " - "novaclient. You should use " - "'novaclient.client.Client' instead. Related lp " - "bug-report: 1493576")) + 403, _("'novaclient.v2.client.Client' is not designed to be " + "initialized directly. It is inner class of " + "novaclient. You should use " + "'novaclient.client.Client' instead. Related lp " + "bug-report: 1493576")) # NOTE(cyeoh): In the novaclient context (unlike Nova) the # project_id is not the same as the tenant_id. Here project_id @@ -244,21 +244,21 @@ class Client(object): @property def projectid(self): - self.logger.warning(_LW("Property 'projectid' is deprecated since " - "Ocata. Use 'project_name' instead.")) + self.logger.warning(_("Property 'projectid' is deprecated since " + "Ocata. Use 'project_name' instead.")) return self.project_name @property def tenant_id(self): - self.logger.warning(_LW("Property 'tenant_id' is deprecated since " - "Ocata. Use 'project_id' instead.")) + self.logger.warning(_("Property 'tenant_id' is deprecated since " + "Ocata. Use 'project_id' instead.")) return self.project_id def __enter__(self): - self.logger.warning(_LW("NovaClient instance can't be used as a " - "context manager since Ocata (deprecated " - "behaviour) since it is redundant in case of " - "SessionClient.")) + self.logger.warning(_("NovaClient instance can't be used as a " + "context manager since Ocata (deprecated " + "behaviour) since it is redundant in case of " + "SessionClient.")) return self def __exit__(self, t, v, tb): @@ -267,9 +267,9 @@ class Client(object): def set_management_url(self, url): self.logger.warning( - _LW("Method `set_management_url` is deprecated since Ocata. " - "Use `endpoint_override` argument instead while initializing " - "novaclient's instance.")) + _("Method `set_management_url` is deprecated since Ocata. " + "Use `endpoint_override` argument instead while initializing " + "novaclient's instance.")) self.client.set_management_url(url) def get_timings(self): @@ -304,5 +304,5 @@ class Client(object): Returns on success; raises :exc:`exceptions.Unauthorized` if the credentials are wrong. """ - self.logger.warning(_LW( + self.logger.warning(_( "Method 'authenticate' is deprecated since Ocata.")) diff --git a/novaclient/v2/contrib/__init__.py b/novaclient/v2/contrib/__init__.py index eb225b881..3cbadc17b 100644 --- a/novaclient/v2/contrib/__init__.py +++ b/novaclient/v2/contrib/__init__.py @@ -13,7 +13,7 @@ import inspect import warnings -from novaclient.i18n import _LW +from novaclient.i18n import _ # NOTE(andreykurilin): "tenant_networks" extension excluded # here deliberately. It was deprecated separately from deprecation @@ -37,15 +37,15 @@ def warn(alternative=True): if module_name.startswith("novaclient.v2.contrib."): if alternative: new_module_name = module_name.replace("contrib.", "") - msg = _LW("Module `%(module)s` is deprecated as of OpenStack " - "Ocata in favor of `%(new_module)s` and will be " - "removed after OpenStack Pike.") % { + msg = _("Module `%(module)s` is deprecated as of OpenStack " + "Ocata in favor of `%(new_module)s` and will be " + "removed after OpenStack Pike.") % { "module": module_name, "new_module": new_module_name} if not alternative: - msg = _LW("Module `%s` is deprecated as of OpenStack Ocata " - "All shell commands were moved to " - "`novaclient.v2.shell` and will be automatically " - "loaded.") % module_name + msg = _("Module `%s` is deprecated as of OpenStack Ocata " + "All shell commands were moved to " + "`novaclient.v2.shell` and will be automatically " + "loaded.") % module_name warnings.warn(msg) diff --git a/novaclient/v2/migrations.py b/novaclient/v2/migrations.py index 9ecc8b38a..075e59d7a 100644 --- a/novaclient/v2/migrations.py +++ b/novaclient/v2/migrations.py @@ -17,7 +17,7 @@ migration interface from six.moves.urllib import parse from novaclient import base -from novaclient.i18n import _LW +from novaclient.i18n import _ class Migration(base.Resource): @@ -41,9 +41,9 @@ class MigrationManager(base.ManagerWithFind): if status: opts['status'] = status if cell_name: - self.client.logger.warning(_LW("Argument 'cell_name' is " - "deprecated since Pike, and will " - "be removed in a future release.")) + self.client.logger.warning(_("Argument 'cell_name' is " + "deprecated since Pike, and will " + "be removed in a future release.")) opts['cell_name'] = cell_name # Transform the dict to a sequence of two-element tuples in fixed diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py index 87b9e6730..48fc4968a 100644 --- a/novaclient/v2/shell.py +++ b/novaclient/v2/shell.py @@ -39,7 +39,6 @@ from novaclient import base from novaclient import client from novaclient import exceptions from novaclient.i18n import _ -from novaclient.i18n import _LE from novaclient import shell from novaclient import utils from novaclient.v2 import availability_zones @@ -70,7 +69,7 @@ def _key_value_pairing(text): (k, v) = text.split('=', 1) return (k, v) except ValueError: - msg = _LE("'%s' is not in the format of 'key=value'") % text + msg = _("'%s' is not in the format of 'key=value'") % text raise argparse.ArgumentTypeError(msg)