Merge "Remove log translations and hacking"
This commit is contained in:
@@ -32,16 +32,6 @@ _C = _translators.contextual_form
|
|||||||
# The plural translation function using the name "_P"
|
# The plural translation function using the name "_P"
|
||||||
_P = _translators.plural_form
|
_P = _translators.plural_form
|
||||||
|
|
||||||
# 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 lazy_translation_enabled():
|
def lazy_translation_enabled():
|
||||||
return _lazy.USE_LAZY
|
return _lazy.USE_LAZY
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ from oslo_log import log
|
|||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from watcher._i18n import _LW
|
|
||||||
from watcher.common import context as watcher_context
|
from watcher.common import context as watcher_context
|
||||||
from watcher.common import scheduling
|
from watcher.common import scheduling
|
||||||
from watcher import notifications
|
from watcher import notifications
|
||||||
@@ -67,9 +66,8 @@ class APISchedulingService(scheduling.BackgroundSchedulerService):
|
|||||||
elapsed = timeutils.delta_seconds(last_heartbeat, timeutils.utcnow())
|
elapsed = timeutils.delta_seconds(last_heartbeat, timeutils.utcnow())
|
||||||
is_up = abs(elapsed) <= CONF.service_down_time
|
is_up = abs(elapsed) <= CONF.service_down_time
|
||||||
if not is_up:
|
if not is_up:
|
||||||
LOG.warning(_LW('Seems service %(name)s on host %(host)s is down. '
|
LOG.warning('Seems service %(name)s on host %(host)s is down. '
|
||||||
'Last heartbeat was %(lhb)s.'
|
'Last heartbeat was %(lhb)s. Elapsed time is %(el)s',
|
||||||
'Elapsed time is %(el)s'),
|
|
||||||
{'name': service.name,
|
{'name': service.name,
|
||||||
'host': service.host,
|
'host': service.host,
|
||||||
'lhb': str(last_heartbeat), 'el': str(elapsed)})
|
'lhb': str(last_heartbeat), 'el': str(elapsed)})
|
||||||
|
|||||||
@@ -15,8 +15,6 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import pep8
|
|
||||||
|
|
||||||
|
|
||||||
def flake8ext(f):
|
def flake8ext(f):
|
||||||
"""Decorator to indicate flake8 extension.
|
"""Decorator to indicate flake8 extension.
|
||||||
@@ -58,29 +56,12 @@ def _regex_for_level(level, hint):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
log_translation_hint = re.compile(
|
|
||||||
'|'.join('(?:%s)' % _regex_for_level(level, hint)
|
|
||||||
for level, hint in _all_log_levels.items()))
|
|
||||||
|
|
||||||
log_warn = re.compile(
|
log_warn = re.compile(
|
||||||
r"(.)*LOG\.(warn)\(\s*('|\"|_)")
|
r"(.)*LOG\.(warn)\(\s*('|\"|_)")
|
||||||
unittest_imports_dot = re.compile(r"\bimport[\s]+unittest\b")
|
unittest_imports_dot = re.compile(r"\bimport[\s]+unittest\b")
|
||||||
unittest_imports_from = re.compile(r"\bfrom[\s]+unittest\b")
|
unittest_imports_from = re.compile(r"\bfrom[\s]+unittest\b")
|
||||||
|
|
||||||
|
|
||||||
@flake8ext
|
|
||||||
def validate_log_translations(logical_line, physical_line, filename):
|
|
||||||
# Translations are not required in the test directory
|
|
||||||
if "watcher/tests" in filename:
|
|
||||||
return
|
|
||||||
if pep8.noqa(physical_line):
|
|
||||||
return
|
|
||||||
|
|
||||||
msg = "N320: Log messages require translation hints!"
|
|
||||||
if log_translation_hint.match(logical_line):
|
|
||||||
yield (0, msg)
|
|
||||||
|
|
||||||
|
|
||||||
@flake8ext
|
@flake8ext
|
||||||
def use_jsonutils(logical_line, filename):
|
def use_jsonutils(logical_line, filename):
|
||||||
msg = "N321: jsonutils.%(fun)s must be used instead of json.%(fun)s"
|
msg = "N321: jsonutils.%(fun)s must be used instead of json.%(fun)s"
|
||||||
@@ -291,7 +272,6 @@ def check_builtins_gettext(logical_line, tokens, filename, lines, noqa):
|
|||||||
|
|
||||||
|
|
||||||
def factory(register):
|
def factory(register):
|
||||||
register(validate_log_translations)
|
|
||||||
register(use_jsonutils)
|
register(use_jsonutils)
|
||||||
register(check_assert_called_once_with)
|
register(check_assert_called_once_with)
|
||||||
register(no_translate_debug_logs)
|
register(no_translate_debug_logs)
|
||||||
|
|||||||
Reference in New Issue
Block a user