Merge "Remove log translations"

This commit is contained in:
Jenkins 2017-06-14 19:26:30 +00:00 committed by Gerrit Code Review
commit 28f1f0f937
15 changed files with 65 additions and 95 deletions

View File

@ -33,8 +33,6 @@ from zaqar.transport import base
from zaqar.transport.middleware import profile
from zaqar.transport import validation
from zaqar.i18n import _LE
LOG = log.getLogger(__name__)
@ -122,8 +120,8 @@ class Bootstrap(object):
return mgr.driver
except RuntimeError as exc:
LOG.exception(exc)
LOG.error(_LE(u'Failed to load transport driver zaqar.transport.'
u'%(driver)s with args %(args)s'),
LOG.error(u'Failed to load transport driver zaqar.transport.'
u'%(driver)s with args %(args)s',
{'driver': transport_name, 'args': args})
raise errors.InvalidDriver(exc)

View File

@ -20,8 +20,6 @@ from oslo_cache import core
from oslo_log import log as logging
from oslo_serialization import jsonutils
from zaqar.i18n import _LW
LOG = logging.getLogger(__name__)
@ -209,12 +207,12 @@ def api_version_manager(version_info):
return None
if deprecated:
LOG.warning(_LW('Enabling API version %(version)s. '
'This version was marked as deprecated in '
'%(updated)s. Using it may expose security '
'issues, unexpected behavior or damage your '
'data.') % {'version': api_version,
'updated': api_updated})
LOG.warning('Enabling API version %(version)s. '
'This version was marked as deprecated in '
'%(updated)s. Using it may expose security '
'issues, unexpected behavior or damage your '
'data.' % {'version': api_version,
'updated': api_updated})
return fn(driver, conf)
return register_api
return wrapper

View File

@ -20,8 +20,6 @@ import hmac
from oslo_utils import timeutils
import six
from zaqar.i18n import _LE
_DATE_FORMAT = '%Y-%m-%dT%H:%M:%S'
@ -44,13 +42,13 @@ def create_signed_url(key, paths, project=None, expires=None, methods=None):
methods = methods or ['GET']
if key is None:
raise ValueError(_LE('The `key` can\'t be None'))
raise ValueError('The `key` can\'t be None')
if not isinstance(paths, list) or not paths:
raise ValueError(_LE('`paths` must be a non-empty list'))
raise ValueError('`paths` must be a non-empty list')
if not isinstance(methods, list):
raise ValueError(_LE('`methods` should be a list'))
raise ValueError('`methods` should be a list')
# NOTE(flaper87): The default expiration time is 1day
# Evaluate whether this should be configurable. We may
@ -65,9 +63,9 @@ def create_signed_url(key, paths, project=None, expires=None, methods=None):
except ValueError:
pass
if check_expires:
raise ValueError(_LE('`expires` should be date format, '
'for example 2016-01-01T00:00:00, '
'not integer value: %s') % check_expires)
raise ValueError('`expires` should be date format, '
'for example 2016-01-01T00:00:00, '
'not integer value: %s' % check_expires)
parsed = timeutils.parse_isotime(expires)
expires = timeutils.normalize_time(parsed)
else:
@ -75,7 +73,7 @@ def create_signed_url(key, paths, project=None, expires=None, methods=None):
expires = timeutils.utcnow() + delta
if expires <= timeutils.utcnow():
raise ValueError(_LE('`expires` is lower than the current time'))
raise ValueError('`expires` is lower than the current time')
methods = sorted(methods)
paths = sorted(paths)

View File

@ -25,13 +25,3 @@ _translators = i18n.TranslatorFactory(domain='zaqar')
# 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

View File

@ -22,8 +22,6 @@ from six.moves import urllib_parse
from zaqar.common import auth
from zaqar.common import urls
from zaqar.i18n import _LE
from zaqar.i18n import _LI
from zaqar.storage import pooling
LOG = logging.getLogger(__name__)
@ -67,8 +65,8 @@ class NotifierDriver(object):
# should allow them be subscribed.
if (self.require_confirmation and
not sub.get('confirmed', True)):
LOG.info(_LI('The subscriber %s is not '
'confirmed.'), sub['subscriber'])
LOG.info('The subscriber %s is not '
'confirmed.', sub['subscriber'])
continue
for msg in messages:
msg['Message_Type'] = MessageType.Notification.name
@ -77,7 +75,7 @@ class NotifierDriver(object):
if not marker:
break
else:
LOG.error(_LE('Failed to get subscription controller.'))
LOG.error('Failed to get subscription controller.')
def send_confirm_notification(self, queue, subscription, conf,
project=None, expires=None,
@ -93,8 +91,8 @@ class NotifierDriver(object):
key = conf.signed_url.secret_key
if not key:
LOG.error(_LE("Can't send confirm notification due to the value of"
" secret_key option is None"))
LOG.error("Can't send confirm notification due to the value of"
" secret_key option is None")
return
url = "/%s/queues/%s/subscriptions/%s/confirm" % (api_version, queue,
subscription['id'])
@ -133,8 +131,8 @@ class NotifierDriver(object):
'SubscribeBody': {'confirmed': True},
'UnsubscribeBody': {'confirmed': False}})
s_type = urllib_parse.urlparse(subscription['subscriber']).scheme
LOG.info(_LI('Begin to send %(type)s confirm/unsubscribe notification.'
' The request body is %(messages)s'),
LOG.info('Begin to send %(type)s confirm/unsubscribe notification.'
' The request body is %(messages)s',
{'type': s_type, 'messages': messages})
self._execute(s_type, subscription, [messages], conf)

View File

@ -20,7 +20,7 @@ import subprocess
from oslo_log import log as logging
from zaqar.i18n import _, _LE
from zaqar.i18n import _
from zaqar.notification.notifier import MessageType
LOG = logging.getLogger(__name__)
@ -101,10 +101,10 @@ class MailtoTask(object):
p.communicate(msg.as_string())
LOG.debug("Send mail successfully: %s", msg.as_string())
except OSError as err:
LOG.exception(_LE('Failed to create process for sendmail, '
'because %s.') % str(err))
LOG.exception('Failed to create process for sendmail, '
'because %s.' % str(err))
except Exception as exc:
LOG.exception(_LE('Failed to send email because %s.') % str(exc))
LOG.exception('Failed to send email because %s.' % str(exc))
def register(self, subscriber, options, ttl, project_id, request_data):
pass

View File

@ -17,8 +17,6 @@ import json
from oslo_log import log as logging
import requests
from zaqar.i18n import _LE
LOG = logging.getLogger(__name__)
@ -43,7 +41,7 @@ class WebhookTask(object):
data=data,
headers=headers)
except Exception as e:
LOG.exception(_LE('webhook task got exception: %s.') % str(e))
LOG.exception('webhook task got exception: %s.' % str(e))
def register(self, subscriber, options, ttl, project_id, request_data):
pass

View File

@ -31,7 +31,6 @@ import pymongo.errors
import pymongo.read_preferences
from zaqar.i18n import _
from zaqar.i18n import _LW
from zaqar import storage
from zaqar.storage import errors
from zaqar.storage.mongodb import utils
@ -451,9 +450,9 @@ class MessageController(storage.Message):
# NOTE(kgriffs): Since we did not filter by a time window,
# the queue should have been found and updated. Perhaps
# the queue has been deleted?
message = _LW(u'Failed to increment the message '
u'counter for queue %(name)s and '
u'project %(project)s')
message = (u'Failed to increment the message '
u'counter for queue %(name)s and '
u'project %(project)s')
message %= dict(name=queue_name, project=project)
LOG.warning(message)
@ -900,8 +899,8 @@ class FIFOMessageController(MessageController):
# this situation can not happen.
elapsed = timeutils.utcnow_ts() - now
if elapsed > MAX_RETRY_POST_DURATION:
msgtmpl = _LW(u'Exceeded maximum retry duration for queue '
u'"%(queue)s" under project %(project)s')
msgtmpl = (u'Exceeded maximum retry duration for queue '
u'"%(queue)s" under project %(project)s')
LOG.warning(msgtmpl,
dict(queue=queue_name, project=project))
@ -944,10 +943,10 @@ class FIFOMessageController(MessageController):
next_marker = self._get_counter(
queue_name, project)
else:
msgtmpl = _LW(u'Detected a stalled message counter '
u'for queue "%(queue)s" under '
u'project %(project)s.'
u'The counter was incremented to %(value)d.')
msgtmpl = (u'Detected a stalled message counter '
u'for queue "%(queue)s" under '
u'project %(project)s.'
u'The counter was incremented to %(value)d.')
LOG.warning(msgtmpl,
dict(queue=queue_name,
@ -961,8 +960,8 @@ class FIFOMessageController(MessageController):
LOG.exception(ex)
raise
msgtmpl = _LW(u'Hit maximum number of attempts (%(max)s) for queue '
u'"%(queue)s" under project %(project)s')
msgtmpl = (u'Hit maximum number of attempts (%(max)s) for queue '
u'"%(queue)s" under project %(project)s')
LOG.warning(msgtmpl,
dict(max=self.driver.mongodb_conf.max_attempts,

View File

@ -28,8 +28,6 @@ from oslo_log import log as logging
from oslo_utils import timeutils
from pymongo import errors
from zaqar.i18n import _LE
from zaqar.i18n import _LW
from zaqar.storage import errors as storage_errors
@ -286,14 +284,14 @@ def retries_on_autoreconnect(func):
break
except errors.AutoReconnect as ex:
LOG.warning(_LW(u'Caught AutoReconnect, retrying the '
'call to {0}').format(func))
LOG.warning(u'Caught AutoReconnect, retrying the '
'call to {0}'.format(func))
last_ex = ex
time.sleep(sleep_sec * (2 ** attempt))
else:
LOG.error(_LE(u'Caught AutoReconnect, maximum attempts '
'to {0} exceeded.').format(func))
LOG.error(u'Caught AutoReconnect, maximum attempts '
'to {0} exceeded.'.format(func))
raise last_ex

View File

@ -23,8 +23,6 @@ from oslo_utils import encodeutils
import redis
import six
from zaqar.i18n import _LE
from zaqar.i18n import _LW
from zaqar.storage import errors
LOG = logging.getLogger(__name__)
@ -203,13 +201,13 @@ def retries_on_connection_error(func):
# MasterNotFoundError.
ex = sys.exc_info()[1]
LOG.warning(_LW(u'Caught ConnectionError, retrying the '
'call to {0}').format(func))
LOG.warning(u'Caught ConnectionError, retrying the '
'call to {0}'.format(func))
time.sleep(sleep_sec * (2 ** attempt))
else:
LOG.error(_LE(u'Caught ConnectionError, maximum attempts '
'to {0} exceeded.').format(func))
LOG.error(u'Caught ConnectionError, maximum attempts '
'to {0} exceeded.'.format(func))
raise ex
return wrapper

View File

@ -22,7 +22,6 @@ from stevedore import driver
from zaqar.common import errors
from zaqar.common import utils
from zaqar.i18n import _LE
from zaqar.storage import configuration
LOG = log.getLogger(__name__)
@ -147,7 +146,7 @@ def load_storage_driver(conf, cache, storage_type=None,
return mgr.driver
except Exception as exc:
LOG.error(_LE('Failed to load "{}" driver for "{}"').format(
LOG.error('Failed to load "{}" driver for "{}"'.format(
driver_type, storage_type))
LOG.exception(exc)
raise errors.InvalidDriver(exc)

View File

@ -35,7 +35,6 @@ from oslo_config import cfg
from oslo_db.sqlalchemy import test_migrations as t_m
from oslo_log import log as logging
from zaqar.i18n import _LE
import zaqar.storage.sqlalchemy.migration
from zaqar.storage.sqlalchemy import tables
@ -160,8 +159,8 @@ class BaseWalkMigrationTestCase(object):
if check:
check(engine, data)
except Exception:
LOG.error(_LE("Failed to migrate to version {version} on engine "
"{engine}").format(version=version, engine=engine))
LOG.error("Failed to migrate to version {version} on engine "
"{engine}".format(version=version, engine=engine))
raise

View File

@ -22,7 +22,6 @@ from osprofiler import _utils as utils
from osprofiler import notifier
from osprofiler import profiler
from osprofiler import web
from zaqar.i18n import _LW
LOG = log.getLogger(__name__)
@ -54,15 +53,15 @@ def setup(conf, binary, host):
_notifier = notifier.create(backend_uri, project="Zaqar",
service=binary, host=host)
notifier.set(_notifier)
LOG.warning(_LW("OSProfiler is enabled.\nIt means that person who "
"knows any of hmac_keys that are specified in "
"/etc/zaqar/zaqar.conf can trace his requests. \n In "
"real life only operator can read this file so there "
"is no security issue. Note that even if person can "
"trigger profiler, only admin user can retrieve trace "
"information.\n"
"To disable OSprofiler set in zaqar.conf:\n"
"[profiler]\nenabled=false"))
LOG.warning("OSProfiler is enabled.\nIt means that person who "
"knows any of hmac_keys that are specified in "
"/etc/zaqar/zaqar.conf can trace his requests. \n In "
"real life only operator can read this file so there "
"is no security issue. Note that even if person can "
"trigger profiler, only admin user can retrieve trace "
"information.\n"
"To disable OSprofiler set in zaqar.conf:\n"
"[profiler]\nenabled=false")
web.enable(conf.profiler.hmac_keys)
else:
web.disable()

View File

@ -38,7 +38,6 @@ except ImportError:
Message = message.MIMEMessage
from zaqar.common import consts
from zaqar.i18n import _LI
LOG = logging.getLogger(__name__)
@ -72,10 +71,10 @@ class MessagingProtocol(websocket.WebSocketServerProtocol):
self._subscriptions = []
def onConnect(self, request):
LOG.info(_LI("Client connecting: %s"), request.peer)
LOG.info("Client connecting: %s", request.peer)
def onOpen(self):
LOG.info(_LI("WebSocket connection open."))
LOG.info("WebSocket connection open.")
def onMessage(self, payload, isBinary):
# Deserialize the request
@ -144,7 +143,7 @@ class MessagingProtocol(websocket.WebSocketServerProtocol):
def onClose(self, wasClean, code, reason):
self._handler.clean_subscriptions(self._subscriptions)
self.factory.unregister(self.proto_id)
LOG.info(_LI("WebSocket connection closed: %s"), reason)
LOG.info("WebSocket connection closed: %s", reason)
def _authenticate(self, payload, in_binary):
self._auth_in_binary = in_binary
@ -217,8 +216,8 @@ class MessagingProtocol(websocket.WebSocketServerProtocol):
body = json.dumps(resp._request._body)
var_dict = {'api': api, 'pack_name': pack_name, 'status':
status, 'action': action, 'body': body}
LOG.info(_LI('Response: API %(api)s %(pack_name)s, %(status)s. '
'Request: action "%(action)s", body %(body)s.'),
LOG.info('Response: API %(api)s %(pack_name)s, %(status)s. '
'Request: action "%(action)s", body %(body)s.',
var_dict)

View File

@ -19,7 +19,6 @@ import six
from zaqar.common import decorators
from zaqar.common import urls
from zaqar.i18n import _LE
from zaqar.transport import acl
from zaqar.transport import utils
from zaqar.transport.wsgi import errors as wsgi_errors
@ -55,7 +54,7 @@ class Resource(object):
diff = set(document.keys()) - _KNOWN_KEYS
if diff:
msg = six.text_type(_LE('Unknown keys: %s') % diff)
msg = six.text_type('Unknown keys: %s' % diff)
raise wsgi_errors.HTTPBadRequestAPI(msg)
key = self._conf.signed_url.secret_key
@ -65,7 +64,7 @@ class Resource(object):
else:
diff = set(paths) - _VALID_PATHS
if diff:
msg = six.text_type(_LE('Invalid paths: %s') % diff)
msg = six.text_type('Invalid paths: %s' % diff)
raise wsgi_errors.HTTPBadRequestAPI(msg)
paths = [os.path.join(req.path[:-6], path) for path in paths]