Merge "Update hacking version"

This commit is contained in:
Zuul 2019-02-20 18:59:03 +00:00 committed by Gerrit Code Review
commit 7102eddb1f
21 changed files with 110 additions and 111 deletions

View File

@ -285,8 +285,8 @@ class AddresserFactory(object):
" present.") " present.")
LOG.warning(w) LOG.warning(w)
if self._mode == 'legacy' or (self._mode == 'dynamic' if self._mode == 'legacy' or (self._mode == 'dynamic' and
and product == 'qpid-cpp'): product == 'qpid-cpp'):
return LegacyAddresser(self._default_exchange, return LegacyAddresser(self._default_exchange,
self._kwargs['legacy_server_prefix'], self._kwargs['legacy_server_prefix'],
self._kwargs['legacy_broadcast_prefix'], self._kwargs['legacy_broadcast_prefix'],

View File

@ -35,11 +35,6 @@ import threading
import time import time
import uuid import uuid
if hasattr(time, 'monotonic'):
now = time.monotonic
else:
from monotonic import monotonic as now # noqa
import proton import proton
import pyngus import pyngus
from six import iteritems from six import iteritems
@ -56,6 +51,11 @@ from oslo_messaging import exceptions
from oslo_messaging.target import Target from oslo_messaging.target import Target
from oslo_messaging import transport from oslo_messaging import transport
if hasattr(time, 'monotonic'):
now = time.monotonic
else:
from monotonic import monotonic as now # noqa
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -491,8 +491,8 @@ class Sender(pyngus.SenderEventHandler):
self._unacked.discard(send_task) self._unacked.discard(send_task)
if state == Sender._ACCEPTED: if state == Sender._ACCEPTED:
send_task._on_ack(Sender._ACCEPTED, info) send_task._on_ack(Sender._ACCEPTED, info)
elif (state == Sender._RELEASED elif (state == Sender._RELEASED or
or (state == Sender._MODIFIED and (state == Sender._MODIFIED and
# assuming delivery-failed means in-doubt: # assuming delivery-failed means in-doubt:
not info.get("delivery-failed") and not info.get("delivery-failed") and
not info.get("undeliverable-here"))): not info.get("undeliverable-here"))):
@ -1337,5 +1337,5 @@ class Controller(pyngus.ConnectionEventHandler):
@property @property
def _active(self): def _active(self):
# Is the connection up # Is the connection up
return (self._socket_connection return (self._socket_connection and
and self._socket_connection.pyngus_conn.active) self._socket_connection.pyngus_conn.active)

View File

@ -28,6 +28,7 @@ import heapq
import logging import logging
import math import math
import os import os
import pyngus
import select import select
import socket import socket
import threading import threading
@ -39,9 +40,6 @@ if hasattr(time, 'monotonic'):
else: else:
from monotonic import monotonic as now # noqa from monotonic import monotonic as now # noqa
import pyngus
from oslo_messaging._i18n import _LE, _LI, _LW
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -103,7 +101,7 @@ class _SocketConnection(object):
if not addr: if not addr:
key = "%s:%i" % (host.hostname, host.port) key = "%s:%i" % (host.hostname, host.port)
error = "Invalid peer address '%s'" % key error = "Invalid peer address '%s'" % key
LOG.error(_LE("Invalid peer address '%s'"), key) LOG.error("Invalid peer address '%s'", key)
self._handler.socket_error(error) self._handler.socket_error(error)
return return
my_socket = socket.socket(addr[0][0], addr[0][1], addr[0][2]) my_socket = socket.socket(addr[0][0], addr[0][1], addr[0][2])
@ -114,7 +112,7 @@ class _SocketConnection(object):
except socket.error as e: except socket.error as e:
if e.errno != errno.EINPROGRESS: if e.errno != errno.EINPROGRESS:
error = "Socket connect failure '%s'" % str(e) error = "Socket connect failure '%s'" % str(e)
LOG.error(_LE("Socket connect failure '%s'"), str(e)) LOG.error("Socket connect failure '%s'", str(e))
self._handler.socket_error(error) self._handler.socket_error(error)
return return
self.socket = my_socket self.socket = my_socket
@ -388,7 +386,7 @@ class Thread(threading.Thread):
select.select(readfds, writefds, [], timeout) select.select(readfds, writefds, [], timeout)
except select.error as serror: except select.error as serror:
if serror[0] == errno.EINTR: if serror[0] == errno.EINTR:
LOG.warning(_LW("ignoring interrupt from select(): %s"), LOG.warning("ignoring interrupt from select(): %s",
str(serror)) str(serror))
continue continue
raise # assuming fatal... raise # assuming fatal...
@ -406,5 +404,5 @@ class Thread(threading.Thread):
self._scheduler._process() # run any deferred requests self._scheduler._process() # run any deferred requests
LOG.info(_LI("eventloop thread exiting, container=%s"), LOG.info("eventloop thread exiting, container=%s",
self._container.name) self._container.name)

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
__all__ = ['AMQPDriverBase']
import logging import logging
import threading import threading
import time import time
@ -33,6 +31,8 @@ from oslo_messaging._i18n import _LE
from oslo_messaging._i18n import _LI from oslo_messaging._i18n import _LI
from oslo_messaging._i18n import _LW from oslo_messaging._i18n import _LW
__all__ = ['AMQPDriverBase']
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
# Minimum/Maximum sleep between a poll and ack/requeue # Minimum/Maximum sleep between a poll and ack/requeue

View File

@ -1094,9 +1094,9 @@ class Connection(object):
info = dict([(k, ci.get(k)) for k in info = dict([(k, ci.get(k)) for k in
['hostname', 'port', 'transport']]) ['hostname', 'port', 'transport']])
client_port = None client_port = None
if (not conn_error and self.channel if (not conn_error and self.channel and
and hasattr(self.channel.connection, 'sock') hasattr(self.channel.connection, 'sock') and
and self.channel.connection.sock): self.channel.connection.sock):
client_port = self.channel.connection.sock.getsockname()[1] client_port = self.channel.connection.sock.getsockname()[1]
info.update({'client_port': client_port, info.update({'client_port': client_port,
'connection_id': self.connection_id}) 'connection_id': self.connection_id})

View File

@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
__all__ = ['ConfFixture']
import sys import sys
import fixtures import fixtures
from functools import wraps from functools import wraps
__all__ = ['ConfFixture']
def _import_opts(conf, module, opts, group=None): def _import_opts(conf, module, opts, group=None):
__import__(module) __import__(module)

View File

@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import six
__all__ = ['MessagingException', 'MessagingTimeout', 'MessageDeliveryFailure', __all__ = ['MessagingException', 'MessagingTimeout', 'MessageDeliveryFailure',
'InvalidTarget'] 'InvalidTarget']
import six
class MessagingException(Exception): class MessagingException(Exception):
"""Base class for exceptions.""" """Base class for exceptions."""

View File

@ -157,8 +157,8 @@ class CheckForLoggingIssues(BaseASTChecker):
"""Return the fully qualified name or a Name or Attribute.""" """Return the fully qualified name or a Name or Attribute."""
if isinstance(node, ast.Name): if isinstance(node, ast.Name):
return node.id return node.id
elif (isinstance(node, ast.Attribute) elif (isinstance(node, ast.Attribute) and
and isinstance(node.value, (ast.Name, ast.Attribute))): isinstance(node.value, (ast.Name, ast.Attribute))):
method_name = node.attr method_name = node.attr
obj_name = self._find_name(node.value) obj_name = self._find_name(node.value)
if obj_name is None: if obj_name is None:
@ -189,8 +189,8 @@ class CheckForLoggingIssues(BaseASTChecker):
""" """
attr_node_types = (ast.Name, ast.Attribute) attr_node_types = (ast.Name, ast.Attribute)
if (len(node.targets) != 1 if (len(node.targets) != 1 or
or not isinstance(node.targets[0], attr_node_types)): not isinstance(node.targets[0], attr_node_types)):
# say no to: "x, y = ..." # say no to: "x, y = ..."
return super(CheckForLoggingIssues, self).generic_visit(node) return super(CheckForLoggingIssues, self).generic_visit(node)
@ -211,13 +211,13 @@ class CheckForLoggingIssues(BaseASTChecker):
return super(CheckForLoggingIssues, self).generic_visit(node) return super(CheckForLoggingIssues, self).generic_visit(node)
# is this a call to an i18n function? # is this a call to an i18n function?
if (isinstance(node.value.func, ast.Name) if (isinstance(node.value.func, ast.Name) and
and node.value.func.id in self.i18n_names): node.value.func.id in self.i18n_names):
self.assignments[target_name] = node.value.func.id self.assignments[target_name] = node.value.func.id
return super(CheckForLoggingIssues, self).generic_visit(node) return super(CheckForLoggingIssues, self).generic_visit(node)
if (not isinstance(node.value.func, ast.Attribute) if (not isinstance(node.value.func, ast.Attribute) or
or not isinstance(node.value.func.value, attr_node_types)): not isinstance(node.value.func.value, attr_node_types)):
# function must be an attribute on an object like # function must be an attribute on an object like
# logging.getLogger # logging.getLogger
return super(CheckForLoggingIssues, self).generic_visit(node) return super(CheckForLoggingIssues, self).generic_visit(node)
@ -225,8 +225,8 @@ class CheckForLoggingIssues(BaseASTChecker):
object_name = self._find_name(node.value.func.value) object_name = self._find_name(node.value.func.value)
func_name = node.value.func.attr func_name = node.value.func.attr
if (object_name in self.logger_module_names if (object_name in self.logger_module_names and
and func_name == 'getLogger'): func_name == 'getLogger'):
self.logger_names.append(target_name) self.logger_names.append(target_name)
return super(CheckForLoggingIssues, self).generic_visit(node) return super(CheckForLoggingIssues, self).generic_visit(node)
@ -250,8 +250,8 @@ class CheckForLoggingIssues(BaseASTChecker):
self.add_error(msg, message=self.USING_DEPRECATED_WARN) self.add_error(msg, message=self.USING_DEPRECATED_WARN)
# must be a logger instance and one of the support logging methods # must be a logger instance and one of the support logging methods
if (obj_name not in self.logger_names if (obj_name not in self.logger_names or
or method_name not in self.TRANS_HELPER_MAP): method_name not in self.TRANS_HELPER_MAP):
return super(CheckForLoggingIssues, self).generic_visit(node) return super(CheckForLoggingIssues, self).generic_visit(node)
# the call must have arguments # the call must have arguments
@ -269,15 +269,15 @@ class CheckForLoggingIssues(BaseASTChecker):
msg = node.args[0] # first arg to a logging method is the msg msg = node.args[0] # first arg to a logging method is the msg
# if first arg is a call to a i18n name # if first arg is a call to a i18n name
if (isinstance(msg, ast.Call) if (isinstance(msg, ast.Call) and
and isinstance(msg.func, ast.Name) isinstance(msg.func, ast.Name) and
and msg.func.id in self.i18n_names): msg.func.id in self.i18n_names):
self.add_error(msg, message=self.DEBUG_CHECK_DESC) self.add_error(msg, message=self.DEBUG_CHECK_DESC)
# if the first arg is a reference to a i18n call # if the first arg is a reference to a i18n call
elif (isinstance(msg, ast.Name) elif (isinstance(msg, ast.Name) and
and msg.id in self.assignments msg.id in self.assignments and
and not self._is_raised_later(node, msg.id)): not self._is_raised_later(node, msg.id)):
self.add_error(msg, message=self.DEBUG_CHECK_DESC) self.add_error(msg, message=self.DEBUG_CHECK_DESC)
def _process_non_debug(self, node, method_name): def _process_non_debug(self, node, method_name):
@ -321,11 +321,11 @@ class CheckForLoggingIssues(BaseASTChecker):
return return
helper_method_name = self.TRANS_HELPER_MAP[method_name] helper_method_name = self.TRANS_HELPER_MAP[method_name]
if (self.assignments[msg.id] != helper_method_name if (self.assignments[msg.id] != helper_method_name and
and not self._is_raised_later(node, msg.id)): not self._is_raised_later(node, msg.id)):
self.add_error(msg, message=self.NONDEBUG_CHECK_DESC) self.add_error(msg, message=self.NONDEBUG_CHECK_DESC)
elif (self.assignments[msg.id] == helper_method_name elif (self.assignments[msg.id] == helper_method_name and
and self._is_raised_later(node, msg.id)): self._is_raised_later(node, msg.id)):
self.add_error(msg, message=self.EXCESS_HELPER_CHECK_DESC) self.add_error(msg, message=self.EXCESS_HELPER_CHECK_DESC)
def _is_raised_later(self, node, name): def _is_raised_later(self, node, name):

View File

@ -13,10 +13,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
__all__ = [
'list_opts'
]
import copy import copy
import itertools import itertools
@ -30,6 +26,9 @@ from oslo_messaging.rpc import client
from oslo_messaging import server from oslo_messaging import server
from oslo_messaging import transport from oslo_messaging import transport
__all__ = [
'list_opts'
]
_global_opt_lists = [ _global_opt_lists = [
drivers_base.base_opts, drivers_base.base_opts,

View File

@ -16,13 +16,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
__all__ = [
'ClientSendError',
'RPCClient',
'RPCVersionCapError',
'RemoteError',
]
import abc import abc
import logging import logging
@ -35,6 +28,12 @@ from oslo_messaging import exceptions
from oslo_messaging import serializer as msg_serializer from oslo_messaging import serializer as msg_serializer
from oslo_messaging import transport as msg_transport from oslo_messaging import transport as msg_transport
__all__ = [
'ClientSendError',
'RPCClient',
'RPCVersionCapError',
'RemoteError',
]
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -16,18 +16,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
__all__ = [
'NoSuchMethod',
'RPCAccessPolicyBase',
'LegacyRPCAccessPolicy',
'DefaultRPCAccessPolicy',
'ExplicitRPCAccessPolicy',
'RPCDispatcher',
'RPCDispatcherError',
'UnsupportedVersion',
'ExpectedException',
]
from abc import ABCMeta from abc import ABCMeta
from abc import abstractmethod from abc import abstractmethod
import logging import logging
@ -42,6 +30,18 @@ from oslo_messaging import serializer as msg_serializer
from oslo_messaging import server as msg_server from oslo_messaging import server as msg_server
from oslo_messaging import target as msg_target from oslo_messaging import target as msg_target
__all__ = [
'NoSuchMethod',
'RPCAccessPolicyBase',
'LegacyRPCAccessPolicy',
'DefaultRPCAccessPolicy',
'ExplicitRPCAccessPolicy',
'RPCDispatcher',
'RPCDispatcherError',
'UnsupportedVersion',
'ExpectedException',
]
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -121,12 +121,6 @@ A simple example of an RPC server with multiple endpoints might be::
""" """
__all__ = [
'get_rpc_server',
'expected_exceptions',
'expose'
]
import logging import logging
import sys import sys
@ -135,6 +129,12 @@ from oslo_messaging.rpc import dispatcher as rpc_dispatcher
from oslo_messaging import server as msg_server from oslo_messaging import server as msg_server
from oslo_messaging import transport as msg_transport from oslo_messaging import transport as msg_transport
__all__ = [
'get_rpc_server',
'expected_exceptions',
'expose'
]
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,12 +13,13 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_messaging import transport as msg_transport
__all__ = [ __all__ = [
'get_rpc_transport' 'get_rpc_transport'
] ]
from oslo_messaging import transport as msg_transport
def get_rpc_transport(conf, url=None, def get_rpc_transport(conf, url=None,
allowed_remote_exmods=None): allowed_remote_exmods=None):

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
__all__ = ['Serializer', 'NoOpSerializer', 'JsonPayloadSerializer']
"""Provides the definition of a message serialization handler""" """Provides the definition of a message serialization handler"""
import abc import abc
@ -21,6 +19,8 @@ import abc
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import six import six
__all__ = ['Serializer', 'NoOpSerializer', 'JsonPayloadSerializer']
@six.add_metaclass(abc.ABCMeta) @six.add_metaclass(abc.ABCMeta)
class Serializer(object): class Serializer(object):

View File

@ -16,13 +16,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
__all__ = [
'ExecutorLoadFailure',
'MessageHandlingServer',
'MessagingServerError',
'ServerListenError',
]
import abc import abc
import functools import functools
import inspect import inspect
@ -42,6 +35,13 @@ from oslo_messaging._drivers import base as driver_base
from oslo_messaging._i18n import _LW from oslo_messaging._i18n import _LW
from oslo_messaging import exceptions from oslo_messaging import exceptions
__all__ = [
'ExecutorLoadFailure',
'MessageHandlingServer',
'MessagingServerError',
'ServerListenError',
]
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
# The default number of seconds of waiting after which we will emit a log # The default number of seconds of waiting after which we will emit a log

View File

@ -51,8 +51,8 @@ if pyngus:
# The Cyrus-based SASL tests can only be run if the installed version of proton # The Cyrus-based SASL tests can only be run if the installed version of proton
# has been built with Cyrus SASL support. # has been built with Cyrus SASL support.
_proton = importutils.try_import("proton") _proton = importutils.try_import("proton")
CYRUS_ENABLED = (pyngus and pyngus.VERSION >= (2, 0, 0) and _proton CYRUS_ENABLED = (pyngus and pyngus.VERSION >= (2, 0, 0) and _proton and
and getattr(_proton.SASL, "extended", lambda: False)()) getattr(_proton.SASL, "extended", lambda: False)())
# same with SSL # same with SSL
# SSL_ENABLED = (_proton and getattr(_proton.SSL, "present", lambda: False)()) # SSL_ENABLED = (_proton and getattr(_proton.SSL, "present", lambda: False)())
SSL_ENABLED = False SSL_ENABLED = False
@ -1305,10 +1305,10 @@ class TestAddressing(test_utils.BaseTestCase):
s1_payload = [m.message.get('msg') for m in rl[0].get_messages()] s1_payload = [m.message.get('msg') for m in rl[0].get_messages()]
s2_payload = [m.message.get('msg') for m in rl[1].get_messages()] s2_payload = [m.message.get('msg') for m in rl[1].get_messages()]
self.assertTrue("Server1" in s1_payload self.assertTrue("Server1" in s1_payload and
and "Server2" not in s1_payload) "Server2" not in s1_payload)
self.assertTrue("Server2" in s2_payload self.assertTrue("Server2" in s2_payload and
and "Server1" not in s2_payload) "Server1" not in s2_payload)
self.assertEqual(s1_payload.count("Fanout"), 1) self.assertEqual(s1_payload.count("Fanout"), 1)
self.assertEqual(s2_payload.count("Fanout"), 1) self.assertEqual(s2_payload.count("Fanout"), 1)
self.assertEqual((s1_payload + s2_payload).count("Anycast1"), 1) self.assertEqual((s1_payload + s2_payload).count("Anycast1"), 1)

View File

@ -153,8 +153,8 @@ class CallTestCase(utils.SkipIfNoTransportURL):
self.assertEqual(10, server.endpoint.ival) self.assertEqual(10, server.endpoint.ival)
def test_monitor_long_call(self): def test_monitor_long_call(self):
if not (self.url.startswith("rabbit://") if not (self.url.startswith("rabbit://") or
or self.url.startswith("amqp://")): self.url.startswith("amqp://")):
self.skipTest("backend does not support call monitoring") self.skipTest("backend does not support call monitoring")
transport = self.useFixture(utils.RPCTransportFixture(self.conf, transport = self.useFixture(utils.RPCTransportFixture(self.conf,

View File

@ -17,16 +17,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
__all__ = [
'DriverLoadFailure',
'InvalidTransportURL',
'Transport',
'TransportHost',
'TransportURL',
'get_transport',
'set_transport_defaults',
]
import logging import logging
from debtcollector import removals from debtcollector import removals
@ -38,6 +28,16 @@ from stevedore import driver
from oslo_messaging._i18n import _LW from oslo_messaging._i18n import _LW
from oslo_messaging import exceptions from oslo_messaging import exceptions
__all__ = [
'DriverLoadFailure',
'InvalidTransportURL',
'Transport',
'TransportHost',
'TransportURL',
'get_transport',
'set_transport_defaults',
]
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_transport_opts = [ _transport_opts = [

View File

@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
# Hacking already pins down pep8, pyflakes and flake8 # Hacking already pins down pep8, pyflakes and flake8
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 hacking>=1.1.0,<1.2.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD fixtures>=3.0.0 # Apache-2.0/BSD
mock>=2.0.0 # BSD mock>=2.0.0 # BSD

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import eventlet import eventlet # noqa
eventlet.monkey_patch() eventlet.monkey_patch() # noqa
import argparse import argparse
import bisect import bisect

View File

@ -99,9 +99,11 @@ basepython = python3
commands = bandit -r oslo_messaging -x tests -n5 commands = bandit -r oslo_messaging -x tests -n5
[flake8] [flake8]
# E731 skipped as assign a lambda expression
show-source = True show-source = True
enable-extensions = H203,H106 enable-extensions = H203,H106
ignore = H405 ignore = E731,H405
exclude = .tox,dist,doc,*.egg,build,__init__.py exclude = .tox,dist,doc,*.egg,build,__init__.py
[hacking] [hacking]