From 9b82953871591575ca2bb217f7c7cf4e9612b50b Mon Sep 17 00:00:00 2001 From: zwei Date: Wed, 9 Mar 2016 11:27:33 +0800 Subject: [PATCH] Exception: message need '_' function eventlet_backdoor.py loopingcall.py service.py Change-Id: I41bf13a2c6afddbffe30ff36134c4a42eaa2ccf1 --- oslo_service/eventlet_backdoor.py | 8 ++++---- oslo_service/loopingcall.py | 6 +++--- oslo_service/service.py | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/oslo_service/eventlet_backdoor.py b/oslo_service/eventlet_backdoor.py index f32ec856..b0bb5f13 100644 --- a/oslo_service/eventlet_backdoor.py +++ b/oslo_service/eventlet_backdoor.py @@ -28,7 +28,7 @@ import traceback import eventlet.backdoor import greenlet -from oslo_service._i18n import _LI +from oslo_service._i18n import _LI, _ from oslo_service import _options @@ -37,8 +37,8 @@ LOG = logging.getLogger(__name__) class EventletBackdoorConfigValueError(Exception): def __init__(self, port_range, help_msg, ex): - msg = ('Invalid backdoor_port configuration %(range)s: %(ex)s. ' - '%(help)s' % + msg = (_('Invalid backdoor_port configuration %(range)s: %(ex)s. ' + '%(help)s') % {'range': port_range, 'ex': ex, 'help': help_msg}) super(EventletBackdoorConfigValueError, self).__init__(msg) self.port_range = port_range @@ -220,7 +220,7 @@ def _main(): where_running_thread = _initialize_if_enabled(conf) if not where_running_thread: - raise RuntimeError("Did not create backdoor at requested location") + raise RuntimeError(_("Did not create backdoor at requested location")) else: _where_running, thread = where_running_thread thread.wait() diff --git a/oslo_service/loopingcall.py b/oslo_service/loopingcall.py index a4a01494..72eaab1d 100644 --- a/oslo_service/loopingcall.py +++ b/oslo_service/loopingcall.py @@ -263,9 +263,9 @@ class BackOffLoopingCall(LoopingCallBase): """ _RNG = random.SystemRandom() - _KIND = 'Dynamic backoff interval looping call' - _RUN_ONLY_ONE_MESSAGE = ("A dynamic backoff interval looping call can" - " only run one function at a time") + _KIND = _('Dynamic backoff interval looping call') + _RUN_ONLY_ONE_MESSAGE = _("A dynamic backoff interval looping call can" + " only run one function at a time") def __init__(self, f=None, *args, **kw): super(BackOffLoopingCall, self).__init__(f=f, *args, **kw) diff --git a/oslo_service/service.py b/oslo_service/service.py index fd636fc5..371d88ea 100644 --- a/oslo_service/service.py +++ b/oslo_service/service.py @@ -35,7 +35,7 @@ from eventlet import event from oslo_concurrency import lockutils from oslo_service import eventlet_backdoor -from oslo_service._i18n import _LE, _LI, _LW +from oslo_service._i18n import _LE, _LI, _LW, _ from oslo_service import _options from oslo_service import systemd from oslo_service import threadgroup @@ -81,7 +81,7 @@ def _is_sighup_and_daemon(signo): def _check_service_base(service): if not isinstance(service, ServiceBase): - raise TypeError("Service %(service)s must an instance of %(base)s!" + raise TypeError(_("Service %(service)s must an instance of %(base)s!") % {'service': service, 'base': ServiceBase}) @@ -696,7 +696,7 @@ def launch(conf, service, workers=1): """ if workers is not None and workers <= 0: - raise ValueError("Number of workers should be positive!") + raise ValueError(_("Number of workers should be positive!")) if workers is None or workers == 1: launcher = ServiceLauncher(conf)