From ee94c48806a868bff8966ce9720bccaf3138ce6c Mon Sep 17 00:00:00 2001 From: Tao Li Date: Tue, 21 Mar 2017 13:05:58 +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: I0a2263090899a86ff922f00feb92d440f9226c4b Closes-Bug: #1674374 --- ironicclient/common/filecache.py | 7 +++--- ironicclient/common/http.py | 18 +++++++-------- ironicclient/common/i18n.py | 10 --------- ironicclient/osc/v1/baremetal_chassis.py | 6 ++--- ironicclient/osc/v1/baremetal_create.py | 6 ++--- ironicclient/osc/v1/baremetal_node.py | 26 +++++++++++----------- ironicclient/osc/v1/baremetal_port.py | 12 +++++----- ironicclient/osc/v1/baremetal_portgroup.py | 6 ++--- 8 files changed, 39 insertions(+), 52 deletions(-) diff --git a/ironicclient/common/filecache.py b/ironicclient/common/filecache.py index 7a7aff8d6..d4fdf348d 100644 --- a/ironicclient/common/filecache.py +++ b/ironicclient/common/filecache.py @@ -20,7 +20,6 @@ import os import appdirs import dogpile.cache -from ironicclient.common.i18n import _LW LOG = logging.getLogger(__name__) @@ -48,9 +47,9 @@ def _get_cache(): try: expiry_time = int(expiry_time) except ValueError: - LOG.warning(_LW("Environment variable %(env_var)s should be an " - "integer (not '%(curr_val)s'). Using default " - "expiry of %(default)s seconds instead."), + LOG.warning("Environment variable %(env_var)s should be an " + "integer (not '%(curr_val)s'). Using default " + "expiry of %(default)s seconds instead.", {'env_var': CACHE_EXPIRY_ENV_VAR, 'curr_val': expiry_time, 'default': DEFAULT_EXPIRY}) diff --git a/ironicclient/common/http.py b/ironicclient/common/http.py index 00fdaee9d..0c6de897f 100644 --- a/ironicclient/common/http.py +++ b/ironicclient/common/http.py @@ -35,8 +35,6 @@ import six.moves.urllib.parse as urlparse from ironicclient.common import filecache from ironicclient.common.i18n import _ -from ironicclient.common.i18n import _LE -from ironicclient.common.i18n import _LW from ironicclient import exc @@ -189,8 +187,8 @@ def with_retries(func): try: return func(self, url, method, **kwargs) except _RETRY_EXCEPTIONS as error: - msg = (_LE("Error contacting Ironic server: %(error)s. " - "Attempt %(attempt)d of %(total)d") % + msg = ("Error contacting Ironic server: %(error)s. " + "Attempt %(attempt)d of %(total)d" % {'attempt': attempt, 'total': num_attempts, 'error': error}) @@ -404,7 +402,7 @@ class HTTPClient(VersionNegotiationMixin): try: body = jsonutils.loads(body) except ValueError: - LOG.error(_LE('Could not decode response body as JSON')) + LOG.error('Could not decode response body as JSON') else: body = None @@ -568,7 +566,7 @@ class SessionClient(VersionNegotiationMixin, adapter.LegacyJsonAdapter): try: body = resp.json() except ValueError: - LOG.error(_LE('Could not decode response body as JSON')) + LOG.error('Could not decode response body as JSON') else: body = None @@ -612,8 +610,8 @@ def _construct_http_client(endpoint=None, dvars = [k for k, v in ignored.items() if v] if dvars: - LOG.warning(_LW('The following arguments are ignored when using ' - 'the session to construct a client: %s'), + LOG.warning('The following arguments are ignored when using ' + 'the session to construct a client: %s', ', '.join(dvars)) return SessionClient(session=session, @@ -625,8 +623,8 @@ def _construct_http_client(endpoint=None, **kwargs) else: if kwargs: - LOG.warning(_LW('The following arguments are being ignored when ' - 'constructing the client: %s'), ', '.join(kwargs)) + LOG.warning('The following arguments are being ignored when ' + 'constructing the client: %s'), ', '.join(kwargs) return HTTPClient(endpoint=endpoint, token=token, diff --git a/ironicclient/common/i18n.py b/ironicclient/common/i18n.py index 35d33b4df..90f289ae7 100644 --- a/ironicclient/common/i18n.py +++ b/ironicclient/common/i18n.py @@ -19,13 +19,3 @@ _translators = oslo_i18n.TranslatorFactory(domain='ironicclient') # 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/ironicclient/osc/v1/baremetal_chassis.py b/ironicclient/osc/v1/baremetal_chassis.py index 777024e9d..a84fc52f4 100644 --- a/ironicclient/osc/v1/baremetal_chassis.py +++ b/ironicclient/osc/v1/baremetal_chassis.py @@ -20,7 +20,7 @@ import logging from osc_lib.command import command from osc_lib import utils as oscutils -from ironicclient.common.i18n import _, _LW +from ironicclient.common.i18n import _ from ironicclient.common import utils from ironicclient import exc from ironicclient.v1 import resource_fields as res_fields @@ -237,7 +237,7 @@ class SetBaremetalChassis(command.Command): if properties: baremetal_client.chassis.update(parsed_args.chassis, properties) else: - self.log.warning(_LW("Please specify what to set.")) + self.log.warning("Please specify what to set.") class ShowBaremetalChassis(command.ShowOne): @@ -322,4 +322,4 @@ class UnsetBaremetalChassis(command.Command): if properties: baremetal_client.chassis.update(parsed_args.chassis, properties) else: - self.log.warning(_LW("Please specify what to unset.")) + self.log.warning("Please specify what to unset.") diff --git a/ironicclient/osc/v1/baremetal_create.py b/ironicclient/osc/v1/baremetal_create.py index a8f3cf957..c16db10b9 100644 --- a/ironicclient/osc/v1/baremetal_create.py +++ b/ironicclient/osc/v1/baremetal_create.py @@ -13,7 +13,7 @@ import argparse import logging -from ironicclient.common.i18n import _, _LW +from ironicclient.common.i18n import _ from ironicclient import exc from ironicclient.osc.v1 import baremetal_node from ironicclient.v1 import create_resources @@ -61,8 +61,8 @@ class CreateBaremetal(baremetal_node.CreateBaremetalNode): def take_action(self, parsed_args): if parsed_args.driver: - self.log.warning(_LW("This command is deprecated. Instead, use " - "'openstack baremetal node create'.")) + self.log.warning("This command is deprecated. Instead, use " + "'openstack baremetal node create'.") return super(CreateBaremetal, self).take_action(parsed_args) if not parsed_args.resource_files: raise exc.ValidationError(_( diff --git a/ironicclient/osc/v1/baremetal_node.py b/ironicclient/osc/v1/baremetal_node.py index 14594cedd..9171bcc62 100755 --- a/ironicclient/osc/v1/baremetal_node.py +++ b/ironicclient/osc/v1/baremetal_node.py @@ -21,7 +21,7 @@ import logging from osc_lib.command import command from osc_lib import utils as oscutils -from ironicclient.common.i18n import _, _LW +from ironicclient.common.i18n import _ from ironicclient.common import utils from ironicclient import exc from ironicclient.v1 import resource_fields as res_fields @@ -471,8 +471,8 @@ class DeleteBaremetal(DeleteBaremetalNode): log = logging.getLogger(__name__ + ".DeleteBaremetal") def take_action(self, parsed_args): - self.log.warning(_LW("This command is deprecated. Instead, use " - "'openstack baremetal node delete'.")) + self.log.warning("This command is deprecated. Instead, use " + "'openstack baremetal node delete'.") super(DeleteBaremetal, self).take_action(parsed_args) @@ -652,8 +652,8 @@ class ListBaremetal(ListBaremetalNode): log = logging.getLogger(__name__ + ".ListBaremetal") def take_action(self, parsed_args): - self.log.warning(_LW("This command is deprecated. Instead, use " - "'openstack baremetal node list'.")) + self.log.warning("This command is deprecated. Instead, use " + "'openstack baremetal node list'.") return super(ListBaremetal, self).take_action(parsed_args) @@ -1053,7 +1053,7 @@ class SetBaremetalNode(command.Command): if properties: baremetal_client.node.update(parsed_args.node, properties) else: - self.log.warning(_LW("Please specify what to set.")) + self.log.warning("Please specify what to set.") class SetBaremetal(SetBaremetalNode): @@ -1063,8 +1063,8 @@ class SetBaremetal(SetBaremetalNode): log = logging.getLogger(__name__ + ".SetBaremetal") def take_action(self, parsed_args): - self.log.warning(_LW("This command is deprecated. Instead, use " - "'openstack baremetal node set'.")) + self.log.warning("This command is deprecated. Instead, use " + "'openstack baremetal node set'.") return super(SetBaremetal, self).take_action(parsed_args) @@ -1128,8 +1128,8 @@ class ShowBaremetal(ShowBaremetalNode): log = logging.getLogger(__name__ + ".ShowBaremetal") def take_action(self, parsed_args): - self.log.warning(_LW("This command is deprecated. Instead, use " - "'openstack baremetal node show'.")) + self.log.warning("This command is deprecated. Instead, use " + "'openstack baremetal node show'.") return super(ShowBaremetal, self).take_action(parsed_args) @@ -1253,7 +1253,7 @@ class UnsetBaremetalNode(command.Command): if properties: baremetal_client.node.update(parsed_args.node, properties) else: - self.log.warning(_LW("Please specify what to unset.")) + self.log.warning("Please specify what to unset.") class UnsetBaremetal(UnsetBaremetalNode): @@ -1263,8 +1263,8 @@ class UnsetBaremetal(UnsetBaremetalNode): log = logging.getLogger(__name__ + ".UnsetBaremetal") def take_action(self, parsed_args): - self.log.warning(_LW("This command is deprecated. Instead, use " - "'openstack baremetal node unset'.")) + self.log.warning("This command is deprecated. Instead, use " + "'openstack baremetal node unset'.") super(UnsetBaremetal, self).take_action(parsed_args) diff --git a/ironicclient/osc/v1/baremetal_port.py b/ironicclient/osc/v1/baremetal_port.py index a99d059ed..f0a3dc64e 100644 --- a/ironicclient/osc/v1/baremetal_port.py +++ b/ironicclient/osc/v1/baremetal_port.py @@ -20,7 +20,7 @@ import logging from osc_lib.command import command from osc_lib import utils as oscutils -from ironicclient.common.i18n import _, _LW +from ironicclient.common.i18n import _ from ironicclient.common import utils from ironicclient import exc from ironicclient.v1 import resource_fields as res_fields @@ -93,9 +93,9 @@ class CreateBaremetalPort(command.ShowOne): baremetal_client = self.app.client_manager.baremetal if parsed_args.local_link_connection_deprecated: - self.log.warning(_LW("Please use --local-link-connection instead " - "of -l, as it is deprecated and will be " - "removed in future releases.")) + self.log.warning("Please use --local-link-connection instead " + "of -l, as it is deprecated and will be " + "removed in future releases.") # It is parsed to either None, or to an array if parsed_args.local_link_connection: parsed_args.local_link_connection.extend( @@ -214,7 +214,7 @@ class UnsetBaremetalPort(command.Command): if properties: baremetal_client.port.update(parsed_args.port, properties) else: - self.log.warning(_LW("Please specify what to unset.")) + self.log.warning("Please specify what to unset.") class SetBaremetalPort(command.Command): @@ -281,7 +281,7 @@ class SetBaremetalPort(command.Command): if properties: baremetal_client.port.update(parsed_args.port, properties) else: - self.log.warning(_LW("Please specify what to set.")) + self.log.warning("Please specify what to set.") class DeleteBaremetalPort(command.Command): diff --git a/ironicclient/osc/v1/baremetal_portgroup.py b/ironicclient/osc/v1/baremetal_portgroup.py index db026cb10..20c7625a5 100644 --- a/ironicclient/osc/v1/baremetal_portgroup.py +++ b/ironicclient/osc/v1/baremetal_portgroup.py @@ -20,7 +20,7 @@ import logging from osc_lib.command import command from osc_lib import utils as oscutils -from ironicclient.common.i18n import _, _LW +from ironicclient.common.i18n import _ from ironicclient.common import utils from ironicclient import exc from ironicclient.v1 import resource_fields as res_fields @@ -392,7 +392,7 @@ class SetBaremetalPortGroup(command.Command): baremetal_client.portgroup.update(parsed_args.portgroup, properties) else: - self.log.warning(_LW("Please specify what to set.")) + self.log.warning("Please specify what to set.") class UnsetBaremetalPortGroup(command.Command): @@ -458,4 +458,4 @@ class UnsetBaremetalPortGroup(command.Command): baremetal_client.portgroup.update(parsed_args.portgroup, properties) else: - self.log.warning(_LW("Please specify what to unset.")) + self.log.warning("Please specify what to unset.")