summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.mailmap4
-rw-r--r--openstack/common/eventlet_backdoor.py2
-rw-r--r--openstack/common/notifier/api.py6
-rw-r--r--openstack/common/policy.py5
-rw-r--r--openstack/common/rpc/impl_kombu.py16
-rw-r--r--openstack/common/rpc/impl_qpid.py13
-rw-r--r--openstack/common/timeutils.py10
-rw-r--r--tests/unit/rpc/test_zmq.py2
-rw-r--r--tests/unit/test_log.py2
-rw-r--r--tests/unit/test_notifier.py71
-rw-r--r--tests/unit/test_utils.py16
-rw-r--r--tools/test-requires2
-rw-r--r--tox.ini2
13 files changed, 96 insertions, 55 deletions
diff --git a/.mailmap b/.mailmap
new file mode 100644
index 0000000..18221d4
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1,4 @@
+# Format is:
+# <preferred e-mail> <other e-mail 1>
+# <preferred e-mail> <other e-mail 2>
+Zhongyue Luo <zhongyue.nah@intel.com> <lzyeval@gmail.com>
diff --git a/openstack/common/eventlet_backdoor.py b/openstack/common/eventlet_backdoor.py
index 9f1404a..a86d24c 100644
--- a/openstack/common/eventlet_backdoor.py
+++ b/openstack/common/eventlet_backdoor.py
@@ -31,7 +31,7 @@ eventlet_backdoor_opts = [
cfg.IntOpt('backdoor_port',
default=None,
help='port for eventlet backdoor to listen')
- ]
+]
CONF = cfg.CONF
CONF.register_opts(eventlet_backdoor_opts)
diff --git a/openstack/common/notifier/api.py b/openstack/common/notifier/api.py
index c22e06c..470eacb 100644
--- a/openstack/common/notifier/api.py
+++ b/openstack/common/notifier/api.py
@@ -139,8 +139,8 @@ def notify(context, publisher_id, event_type, priority, payload):
driver.notify(context, msg)
except Exception, e:
LOG.exception(_("Problem '%(e)s' attempting to "
- "send to notification system. Payload=%(payload)s") %
- locals())
+ "send to notification system. "
+ "Payload=%(payload)s") % locals())
_drivers = None
@@ -169,7 +169,7 @@ def add_driver(notification_driver):
except ImportError as e:
LOG.exception(_("Failed to load notifier %s. "
"These notifications will not be sent.") %
- notification_driver)
+ notification_driver)
else:
# Driver is already loaded; just add the object.
_drivers[notification_driver] = notification_driver
diff --git a/openstack/common/policy.py b/openstack/common/policy.py
index 4cd5a43..a4064cf 100644
--- a/openstack/common/policy.py
+++ b/openstack/common/policy.py
@@ -172,8 +172,9 @@ class Brain(object):
else:
LOG.warning(_("Inheritance-based rules are deprecated; update "
"_check_%s") % match_kind)
- func = (lambda brain, kind, value, target, cred:
- old_func(value, target, cred))
+ func = lambda brain, kind, value, target, cred: old_func(value,
+ target,
+ cred)
if not func:
LOG.error(_("No handler for matches of kind %s") % match_kind)
diff --git a/openstack/common/rpc/impl_kombu.py b/openstack/common/rpc/impl_kombu.py
index 294fc0a..8617bfc 100644
--- a/openstack/common/rpc/impl_kombu.py
+++ b/openstack/common/rpc/impl_kombu.py
@@ -210,10 +210,11 @@ class TopicConsumer(ConsumerBase):
'auto_delete': False,
'exclusive': False}
options.update(kwargs)
- exchange = kombu.entity.Exchange(
- name=rpc_amqp.get_control_exchange(conf),
- type='topic', durable=options['durable'],
- auto_delete=options['auto_delete'])
+ exchange_name = rpc_amqp.get_control_exchange(conf)
+ exchange = kombu.entity.Exchange(name=exchange_name,
+ type='topic',
+ durable=options['durable'],
+ auto_delete=options['auto_delete'])
super(TopicConsumer, self).__init__(channel,
callback,
tag,
@@ -307,9 +308,12 @@ class TopicPublisher(Publisher):
'auto_delete': False,
'exclusive': False}
options.update(kwargs)
+ exchange_name = rpc_amqp.get_control_exchange(conf)
super(TopicPublisher, self).__init__(channel,
- rpc_amqp.get_control_exchange(conf), topic,
- type='topic', **options)
+ exchange_name,
+ topic,
+ type='topic',
+ **options)
class FanoutPublisher(Publisher):
diff --git a/openstack/common/rpc/impl_qpid.py b/openstack/common/rpc/impl_qpid.py
index 93d771c..1b3031c 100644
--- a/openstack/common/rpc/impl_qpid.py
+++ b/openstack/common/rpc/impl_qpid.py
@@ -180,9 +180,10 @@ class TopicConsumer(ConsumerBase):
:param name: optional queue name, defaults to topic
"""
+ exchange_name = rpc_amqp.get_control_exchange(conf)
super(TopicConsumer, self).__init__(session, callback,
- "%s/%s" % (rpc_amqp.get_control_exchange(conf), topic),
- {}, name or topic, {})
+ "%s/%s" % (exchange_name, topic),
+ {}, name or topic, {})
class FanoutConsumer(ConsumerBase):
@@ -255,8 +256,9 @@ class TopicPublisher(Publisher):
def __init__(self, conf, session, topic):
"""init a 'topic' publisher.
"""
+ exchange_name = rpc_amqp.get_control_exchange(conf)
super(TopicPublisher, self).__init__(session,
- "%s/%s" % (rpc_amqp.get_control_exchange(conf), topic))
+ "%s/%s" % (exchange_name, topic))
class FanoutPublisher(Publisher):
@@ -274,9 +276,10 @@ class NotifyPublisher(Publisher):
def __init__(self, conf, session, topic):
"""init a 'topic' publisher.
"""
+ exchange_name = rpc_amqp.get_control_exchange(conf)
super(NotifyPublisher, self).__init__(session,
- "%s/%s" % (rpc_amqp.get_control_exchange(conf), topic),
- {"durable": True})
+ "%s/%s" % (exchange_name, topic),
+ {"durable": True})
class Connection(object):
diff --git a/openstack/common/timeutils.py b/openstack/common/timeutils.py
index c4f6cf0..9901a4c 100644
--- a/openstack/common/timeutils.py
+++ b/openstack/common/timeutils.py
@@ -121,6 +121,10 @@ def marshall_now(now=None):
def unmarshall_time(tyme):
"""Unmarshall a datetime dict."""
- return datetime.datetime(day=tyme['day'], month=tyme['month'],
- year=tyme['year'], hour=tyme['hour'], minute=tyme['minute'],
- second=tyme['second'], microsecond=tyme['microsecond'])
+ return datetime.datetime(day=tyme['day'],
+ month=tyme['month'],
+ year=tyme['year'],
+ hour=tyme['hour'],
+ minute=tyme['minute'],
+ second=tyme['second'],
+ microsecond=tyme['microsecond'])
diff --git a/tests/unit/rpc/test_zmq.py b/tests/unit/rpc/test_zmq.py
index 551e63b..058737f 100644
--- a/tests/unit/rpc/test_zmq.py
+++ b/tests/unit/rpc/test_zmq.py
@@ -107,7 +107,7 @@ class _RpcZmqBaseTestCase(common.BaseRpcTestCase):
self.reactor.consume_in_thread()
except zmq.ZMQError:
LOG.error(_("Could not create ZeroMQ receiver daemon. "
- "Socket may already be in use."))
+ "Socket may already be in use."))
raise
def tearDown(self):
diff --git a/tests/unit/test_log.py b/tests/unit/test_log.py
index 9c86f8d..b64fe8c 100644
--- a/tests/unit/test_log.py
+++ b/tests/unit/test_log.py
@@ -265,7 +265,7 @@ class FancyRecordTestCase(test_utils.BaseTestCase):
self.colorlog.info("foo")
self.assertNotEqual(sys.stderr.getvalue().find("KeyError: 'missing'"),
- -1)
+ -1)
sys.stderr = error
diff --git a/tests/unit/test_notifier.py b/tests/unit/test_notifier.py
index e5c69b4..1cabae0 100644
--- a/tests/unit/test_notifier.py
+++ b/tests/unit/test_notifier.py
@@ -32,8 +32,10 @@ class NotifierTestCase(test_utils.BaseTestCase):
"""Test case for notifications"""
def setUp(self):
super(NotifierTestCase, self).setUp()
- self.config(notification_driver=['openstack.common.'
- 'notifier.no_op_notifier'])
+ notification_driver = [
+ 'openstack.common.notifier.no_op_notifier'
+ ]
+ self.config(notification_driver=notification_driver)
self.config(default_publisher_id='publisher')
def tearDown(self):
@@ -234,40 +236,60 @@ class MultiNotifierTestCase(test_utils.BaseTestCase):
super(MultiNotifierTestCase, self).tearDown()
def test_send_notifications_successfully(self):
- self.config(notification_driver=[
- 'openstack.common.notifier.no_op_notifier'])
- notifier_api.notify('contextarg', 'publisher_id', 'event_type',
- notifier_api.WARN, dict(a=3))
+ notification_driver = [
+ 'openstack.common.notifier.no_op_notifier'
+ ]
+ self.config(notification_driver=notification_driver)
+ notifier_api.notify('contextarg',
+ 'publisher_id',
+ 'event_type',
+ notifier_api.WARN,
+ dict(a=3))
self.assertEqual(self.notify_count, 1)
self.assertEqual(self.exception_count, 0)
def test_send_notifications_with_errors(self):
- self.config(notification_driver=[
- 'openstack.common.notifier.no_op_notifier',
- 'openstack.common.notifier.log_notifier'])
- notifier_api.notify('contextarg', 'publisher_id',
- 'event_type', notifier_api.WARN, dict(a=3))
+ notification_driver = [
+ 'openstack.common.notifier.no_op_notifier',
+ 'openstack.common.notifier.log_notifier'
+ ]
+ self.config(notification_driver=notification_driver)
+ notifier_api.notify('contextarg',
+ 'publisher_id',
+ 'event_type',
+ notifier_api.WARN,
+ dict(a=3))
self.assertEqual(self.notify_count, 1)
self.assertEqual(self.exception_count, 1)
def test_when_driver_fails_to_import(self):
- self.config(notification_driver=[
- 'openstack.common.notifier.no_op_notifier',
- 'openstack.common.notifier.logo_notifier',
- 'fdsjgsdfhjkhgsfkj'])
- notifier_api.notify('contextarg', 'publisher_id',
- 'event_type', notifier_api.WARN, dict(a=3))
+ notification_driver = [
+ 'openstack.common.notifier.no_op_notifier',
+ 'openstack.common.notifier.logo_notifier',
+ 'fdsjgsdfhjkhgsfkj'
+ ]
+ self.config(notification_driver=notification_driver)
+ notifier_api.notify('contextarg',
+ 'publisher_id',
+ 'event_type',
+ notifier_api.WARN,
+ dict(a=3))
self.assertEqual(self.exception_count, 2)
self.assertEqual(self.notify_count, 1)
def test_adding_and_removing_notifier_object(self):
self.notifier_object = SimpleNotifier()
- self.config(notification_driver=[
- 'openstack.common.notifier.no_op_notifier'])
+ notification_driver = [
+ 'openstack.common.notifier.no_op_notifier'
+ ]
+ self.config(notification_driver=notification_driver)
notifier_api.add_driver(self.notifier_object)
- notifier_api.notify(None, 'publisher_id', 'event_type',
- notifier_api.WARN, dict(a=3))
+ notifier_api.notify(None,
+ 'publisher_id',
+ 'event_type',
+ notifier_api.WARN,
+ dict(a=3))
self.assertEqual(self.notify_count, 1)
self.assertTrue(self.notifier_object.notified)
@@ -277,6 +299,9 @@ class MultiNotifierTestCase(test_utils.BaseTestCase):
self.config(notification_driver=[])
notifier_api.add_driver('openstack.common.notifier.no_op_notifier')
- notifier_api.notify(None, 'publisher_id', 'event_type',
- notifier_api.WARN, dict(a=3))
+ notifier_api.notify(None,
+ 'publisher_id',
+ 'event_type',
+ notifier_api.WARN,
+ dict(a=3))
self.assertEqual(self.notify_count, 1)
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py
index 25280f9..7dadf72 100644
--- a/tests/unit/test_utils.py
+++ b/tests/unit/test_utils.py
@@ -83,17 +83,17 @@ class UtilsTest(unittest.TestCase):
def test_parse_host_port(self):
self.assertEqual(('server01', 80),
- utils.parse_host_port('server01:80'))
+ utils.parse_host_port('server01:80'))
self.assertEqual(('server01', None),
- utils.parse_host_port('server01'))
+ utils.parse_host_port('server01'))
self.assertEqual(('server01', 1234),
- utils.parse_host_port('server01', default_port=1234))
+ utils.parse_host_port('server01', default_port=1234))
self.assertEqual(('::1', 80),
- utils.parse_host_port('[::1]:80'))
+ utils.parse_host_port('[::1]:80'))
self.assertEqual(('::1', None),
- utils.parse_host_port('[::1]'))
+ utils.parse_host_port('[::1]'))
self.assertEqual(('::1', 1234),
- utils.parse_host_port('[::1]', default_port=1234))
+ utils.parse_host_port('[::1]', default_port=1234))
self.assertEqual(('2001:db8:85a3::8a2e:370:7334', 1234),
- utils.parse_host_port('2001:db8:85a3::8a2e:370:7334',
- default_port=1234))
+ utils.parse_host_port('2001:db8:85a3::8a2e:370:7334',
+ default_port=1234))
diff --git a/tools/test-requires b/tools/test-requires
index 1151174..986567c 100644
--- a/tools/test-requires
+++ b/tools/test-requires
@@ -9,7 +9,7 @@ nose-exclude
nosexcover
openstack.nose_plugin
nosehtmloutput
-pep8==0.6.1
+pep8==1.3.3
pylint
setuptools-git>=0.4
sphinx
diff --git a/tox.ini b/tox.ini
index f18e7c0..d4b849b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -15,7 +15,7 @@ deps = -r{toxinidir}/tools/pip-requires
commands = nosetests {posargs}
[testenv:pep8]
-deps = pep8==1.1
+deps = pep8==1.3.3
commands = pep8 --repeat --show-source --ignore=E125 --exclude=.venv,.tox,dist,doc,*.egg .
[testenv:cover]