diff --git a/.gitignore b/.gitignore index f42c2b3c86f7cef0dbb423186b340ff18e37b34d..5c528f964aa7b08cb10b3b0da3d3248894079b25 100644 --- a/.gitignore +++ b/.gitignore @@ -91,3 +91,4 @@ ENV/ .vagrant/ .idea/ +MANIFEST diff --git a/.travis.yml b/.travis.yml index 8c29529ba97729f7473c41cbbc23eb838bb63a07..4a4d90110ffe4c7dade33c79dbcbf6f0997d4eb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ language: python python: - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5 - "pypy" cache: pip sudo: required diff --git a/README.md b/README.md index b874c4909d30a4b8aa4bb1cfb9a81518315c68b9..714c1c319fe429026215cd1b4356962f016dfbc3 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ CoolAMQP []() []() -**Support for Python 3 is suspended until I fix pending issues** - When you're tired of fucking with AMQP reconnects. When a connection made by CoolAMQP to your broker fails, it will pick another diff --git a/Vagrantfile b/Vagrantfile index 25d3c70815ede7cf5a381f2a1e59dbf446a6acd6..d395929114da4a38465a03135e02af3bdc9e0b11 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -13,8 +13,11 @@ Vagrant.configure("2") do |config| config.vm.provision "shell", inline: <<-SHELL apt-get update - apt-get install -y htop curl python python-setuptools python-pip python-dev build-essential rabbitmq-server + + # Python + apt-get install -y htop curl python python-setuptools python-pip python-dev build-essential rabbitmq-server python3 python3-pip python3-setuptools pip install --upgrade pip setuptools + pip3 install --upgrade pip setuptools /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management sudo service rabbitmq-server restart @@ -25,6 +28,8 @@ Vagrant.configure("2") do |config| # Install deps pip install -r /vagrant/requirements.txt pip install nose coverage + pip3 install -r /vagrant/requirements.txt + pip3 install nose coverage # HTTP server for viewing coverage reports apt-get -y install nginx diff --git a/coolamqp/backends/base.py b/coolamqp/backends/base.py index 401b89775beb82a95d20bb5999a5845823a3c99b..4959e3606894b6cb4909783759440d803da7fed5 100644 --- a/coolamqp/backends/base.py +++ b/coolamqp/backends/base.py @@ -9,6 +9,7 @@ class ConnectionFailedError(AMQPError): class Cancelled(Exception): """Cancel ordered by user""" + class RemoteAMQPError(AMQPError): """ Remote AMQP broker responded with an error code diff --git a/coolamqp/backends/pyamqp.py b/coolamqp/backends/pyamqp.py index 90bbbe3805d0a1277e66b6d7279587fa52116c34..12ae1a052cb27796dd9bd9ef904932501057150f 100644 --- a/coolamqp/backends/pyamqp.py +++ b/coolamqp/backends/pyamqp.py @@ -3,6 +3,7 @@ from __future__ import division import amqp import socket +import six import functools import logging from .base import AMQPBackend, RemoteAMQPError, ConnectionFailedError @@ -21,7 +22,8 @@ def translate_exceptions(fun): except amqp.RecoverableChannelError as e: raise RemoteAMQPError(e.reply_code, e.reply_text) except (IOError, amqp.ConnectionForced, amqp.IrrecoverableChannelError) as e: - raise ConnectionFailedError(e.message) + msg = e.message if six.PY2 else e.args[0] + raise ConnectionFailedError(msg) return q diff --git a/setup.py b/setup.py index 554ba11a93740b172e4a7ca4ab5c03abfbf3a081..b3f06c73ca4da0140bbab770a4d174ea7671c103 100644 --- a/setup.py +++ b/setup.py @@ -2,10 +2,16 @@ # coding=UTF-8 from setuptools import setup + +def reqs(): + with open('requirements.txt', 'r') as fin: + return [q.strip() for q in fin.readlines() if len(q.strip()) > 0] + + setup(name='CoolAMQP', version='0.7', - description=u'AMQP client with sane reconnects', - author=u'DMS Serwis s.c.', + description='AMQP client with sane reconnects', + author='DMS Serwis s.c.', author_email='piotrm@smok.co', url='https://github.com/smok-serwis/coolamqp', download_url='https://github.com/smok-serwis/coolamqp/archive/v0.7.zip', @@ -13,18 +19,16 @@ setup(name='CoolAMQP', packages=['coolamqp', 'coolamqp.backends'], license='MIT License', long_description=u'The AMQP client that handles reconnection madness for you', - requires=[ - "amqp", - "six", - "monotonic" - ], + requires=reqs(), tests_require=["nose"], test_suite='nose.collector', classifiers=[ 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', -# 'Programming Language :: Python :: 3.4', -# 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Operating System :: OS Independent' diff --git a/tests/test_basics.py b/tests/test_basics.py index ed1e4e21ea5fa18b11e31f9958edbb138eafe037..e633f6c43362b8568783f4bb86f46f7954233313 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -3,8 +3,7 @@ from __future__ import absolute_import, division, print_function import unittest import six -from coolamqp import Cluster, ClusterNode, Queue, MessageReceived, ConnectionUp, \ - ConnectionDown, ConsumerCancelled, Message, Exchange +from coolamqp import Cluster, ClusterNode, Queue, MessageReceived, ConnectionUp, ConsumerCancelled, Message, Exchange def getamqp(): @@ -55,7 +54,7 @@ class TestBasics(unittest.TestCase): p = self.amqp.drain(wait=4) self.assertIsInstance(p, MessageReceived) - self.assertEquals(six.binary_type(p.message.body), 'what the fuck') + self.assertEquals(six.text_type(p.message.body), 'what the fuck') def test_bug_hangs(self): p = Queue('lol', exclusive=True)