diff options
author | Ask Solem <ask@celeryproject.org> | 2012-11-08 20:20:41 +0000 |
---|---|---|
committer | Ask Solem <ask@celeryproject.org> | 2012-11-08 20:20:41 +0000 |
commit | 7f9b38ff8bd59540f5304fbe391fd0987b48c805 (patch) | |
tree | 63090b99d6372d6dbff13e4a75c724f9f6e0f4ed | |
parent | 3405974b5f9cac6fd0f664cca52f7b1af8e47fcf (diff) | |
download | kombu-7f9b38ff8bd59540f5304fbe391fd0987b48c805.tar.gz |
[kombu3] No longer supports Python 2.5
47 files changed, 85 insertions, 254 deletions
diff --git a/examples/complete_receive.py b/examples/complete_receive.py index d7c8e948..3d9d44a9 100644 --- a/examples/complete_receive.py +++ b/examples/complete_receive.py @@ -2,9 +2,6 @@ Example of simple consumer that waits for a single message, acknowledges it and exits. """ - -from __future__ import with_statement - from kombu import Connection, Exchange, Queue, Consumer, eventloop from pprint import pformat diff --git a/examples/complete_send.py b/examples/complete_send.py index c81f8620..337083c1 100644 --- a/examples/complete_send.py +++ b/examples/complete_send.py @@ -5,8 +5,6 @@ Example producer that sends a single message and exits. You can use `complete_receive.py` to receive the message sent. """ -from __future__ import with_statement - from kombu import Connection, Producer, Exchange, Queue #: By default messages sent to exchanges are persistent (delivery_mode=2), diff --git a/examples/simple_eventlet_receive.py b/examples/simple_eventlet_receive.py index 1f88e713..d70126df 100644 --- a/examples/simple_eventlet_receive.py +++ b/examples/simple_eventlet_receive.py @@ -6,8 +6,6 @@ You can use `simple_receive.py` (or `complete_receive.py`) to receive the message sent. """ -from __future__ import with_statement - import eventlet from Queue import Empty diff --git a/examples/simple_eventlet_send.py b/examples/simple_eventlet_send.py index f6259bf3..1ba87fbf 100644 --- a/examples/simple_eventlet_send.py +++ b/examples/simple_eventlet_send.py @@ -6,8 +6,6 @@ You can use `simple_receive.py` (or `complete_receive.py`) to receive the message sent. """ -from __future__ import with_statement - import eventlet from kombu import Connection diff --git a/examples/simple_receive.py b/examples/simple_receive.py index e9b933b1..e15427e3 100644 --- a/examples/simple_receive.py +++ b/examples/simple_receive.py @@ -1,9 +1,6 @@ """ Example receiving a message using the SimpleQueue interface. """ - -from __future__ import with_statement - from kombu import Connection #: Create connection diff --git a/examples/simple_send.py b/examples/simple_send.py index e76fbcf0..3b3f236e 100644 --- a/examples/simple_send.py +++ b/examples/simple_send.py @@ -6,8 +6,6 @@ You can use `simple_receive.py` (or `complete_receive.py`) to receive the message sent. """ -from __future__ import with_statement - from kombu import Connection #: Create connection diff --git a/examples/simple_task_queue/client.py b/examples/simple_task_queue/client.py index fe0a512b..8ed33f36 100644 --- a/examples/simple_task_queue/client.py +++ b/examples/simple_task_queue/client.py @@ -1,5 +1,3 @@ -from __future__ import with_statement - from kombu.common import maybe_declare from kombu.pools import producers diff --git a/examples/simple_task_queue/worker.py b/examples/simple_task_queue/worker.py index be241140..807542e9 100644 --- a/examples/simple_task_queue/worker.py +++ b/examples/simple_task_queue/worker.py @@ -1,5 +1,3 @@ -from __future__ import with_statement - from kombu.mixins import ConsumerMixin from kombu.log import get_logger from kombu.utils import kwdict, reprcall @@ -25,7 +23,7 @@ class Worker(ConsumerMixin): logger.info('Got task: %s', reprcall(fun.__name__, args, kwargs)) try: fun(*args, **kwdict(kwargs)) - except Exception, exc: + except Exception as exc: logger.error('task raised exception: %r', exc) message.ack() diff --git a/extra/release/bump_version.py b/extra/release/bump_version.py index ccf7355e..d7b9c6fd 100755 --- a/extra/release/bump_version.py +++ b/extra/release/bump_version.py @@ -1,7 +1,6 @@ #!/usr/bin/env python from __future__ import absolute_import -from __future__ import with_statement import errno import os @@ -23,7 +22,7 @@ def cmd(*args): def no_enoent(): try: yield - except OSError, exc: + except OSError as exc: if exc.errno != errno.ENOENT: raise diff --git a/extra/release/flakeplus.py b/extra/release/flakeplus.py deleted file mode 100755 index 6fe1f1fc..00000000 --- a/extra/release/flakeplus.py +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env python -from __future__ import absolute_import -from __future__ import with_statement - -import os -import re -import sys - -from collections import defaultdict -from unipath import Path - -RE_COMMENT = r'^\s*\#' -RE_NOQA = r'.+?\#\s+noqa+' -RE_MULTILINE_COMMENT_O = r'^\s*(?:\'\'\'|""").+?(?:\'\'\'|""")' -RE_MULTILINE_COMMENT_S = r'^\s*(?:\'\'\'|""")' -RE_MULTILINE_COMMENT_E = r'(?:^|.+?)(?:\'\'\'|""")' -RE_WITH = r'(?:^|\s+)with\s+' -RE_WITH_IMPORT = r'''from\s+ __future__\s+ import\s+ with_statement''' -RE_PRINT = r'''(?:^|\s+)print\((?:"|')(?:\W+?)?[A-Z0-9:]{2,}''' -RE_ABS_IMPORT = r'''from\s+ __future__\s+ import\s+ absolute_import''' - -acc = defaultdict(lambda: {"abs": False, "print": False}) - - -def compile(regex): - return re.compile(regex, re.VERBOSE) - - -class FlakePP(object): - re_comment = compile(RE_COMMENT) - re_ml_comment_o = compile(RE_MULTILINE_COMMENT_O) - re_ml_comment_s = compile(RE_MULTILINE_COMMENT_S) - re_ml_comment_e = compile(RE_MULTILINE_COMMENT_E) - re_abs_import = compile(RE_ABS_IMPORT) - re_print = compile(RE_PRINT) - re_with_import = compile(RE_WITH_IMPORT) - re_with = compile(RE_WITH) - re_noqa = compile(RE_NOQA) - map = {"abs": True, "print": False, - "with": False, "with-used": False} - - def __init__(self, verbose=False): - self.verbose = verbose - self.steps = (("abs", self.re_abs_import), - ("with", self.re_with_import), - ("with-used", self.re_with), - ("print", self.re_print)) - - def analyze_fh(self, fh): - steps = self.steps - filename = fh.name - acc = dict(self.map) - index = 0 - errors = [0] - - def error(fmt, **kwargs): - errors[0] += 1 - self.announce(fmt, **dict(kwargs, filename=filename)) - - for index, line in enumerate(self.strip_comments(fh)): - for key, pattern in steps: - if pattern.match(line): - acc[key] = True - if index: - if not acc["abs"]: - error("%(filename)s: missing abs import") - if acc["with-used"] and not acc["with"]: - error("%(filename)s: missing with import") - if acc["print"]: - error("%(filename)s: left over print statement") - - return filename, errors[0], acc - - def analyze_file(self, filename): - with open(filename) as fh: - return self.analyze_fh(fh) - - def analyze_tree(self, dir): - for dirpath, _, filenames in os.walk(dir): - for path in (Path(dirpath, f) for f in filenames): - if path.endswith(".py"): - yield self.analyze_file(path) - - def analyze(self, *paths): - for path in map(Path, paths): - if path.isdir(): - for res in self.analyze_tree(path): - yield res - else: - yield self.analyze_file(path) - - def strip_comments(self, fh): - re_comment = self.re_comment - re_ml_comment_o = self.re_ml_comment_o - re_ml_comment_s = self.re_ml_comment_s - re_ml_comment_e = self.re_ml_comment_e - re_noqa = self.re_noqa - in_ml = False - - for line in fh.readlines(): - if in_ml: - if re_ml_comment_e.match(line): - in_ml = False - else: - if re_noqa.match(line) or re_ml_comment_o.match(line): - pass - elif re_ml_comment_s.match(line): - in_ml = True - elif re_comment.match(line): - pass - else: - yield line - - def announce(self, fmt, **kwargs): - sys.stderr.write((fmt + "\n") % kwargs) - - -def main(argv=sys.argv, exitcode=0): - for _, errors, _ in FlakePP(verbose=True).analyze(*argv[1:]): - if errors: - exitcode = 1 - return exitcode - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/funtests/transport.py b/funtests/transport.py index 5924a72a..4df10738 100644 --- a/funtests/transport.py +++ b/funtests/transport.py @@ -79,7 +79,7 @@ class TransportCase(unittest.TestCase): if self.transport: try: self.before_connect() - except SkipTest, exc: + except SkipTest as exc: self.skip_test_reason = str(exc) else: self.do_connect() diff --git a/kombu/clocks.py b/kombu/clocks.py index 9a62ed05..8d0da2fe 100644 --- a/kombu/clocks.py +++ b/kombu/clocks.py @@ -9,7 +9,6 @@ Logical Clocks and Synchronization. """ from __future__ import absolute_import -from __future__ import with_statement import threading diff --git a/kombu/common.py b/kombu/common.py index af4d40f2..ee83ab0a 100644 --- a/kombu/common.py +++ b/kombu/common.py @@ -9,7 +9,6 @@ Common Utilities. """ from __future__ import absolute_import -from __future__ import with_statement import os import socket diff --git a/kombu/connection.py b/kombu/connection.py index 4b7042bd..53a69933 100644 --- a/kombu/connection.py +++ b/kombu/connection.py @@ -9,7 +9,6 @@ Broker connection and pools. """ from __future__ import absolute_import -from __future__ import with_statement import errno import os @@ -287,7 +286,7 @@ class Connection(object): except socket.timeout: self.more_to_read = False return False - except socket.error, exc: + except socket.error as exc: if exc.errno in (errno.EAGAIN, errno.EINTR): self.more_to_read = False return False @@ -423,7 +422,7 @@ class Connection(object): for retries in count(0): # for infinity try: return fun(*args, **kwargs) - except self.connection_errors, exc: + except self.connection_errors as exc: if got_connection: raise if max_retries is not None and retries > max_retries: @@ -446,7 +445,7 @@ class Connection(object): if on_revive: on_revive(new_channel) got_connection += 1 - except self.channel_errors, exc: + except self.channel_errors as exc: if max_retries is not None and retries > max_retries: raise self._debug('ensure channel error: %r', exc, exc_info=1) diff --git a/kombu/messaging.py b/kombu/messaging.py index afa5ee15..0c3e7421 100644 --- a/kombu/messaging.py +++ b/kombu/messaging.py @@ -499,7 +499,7 @@ class Consumer(object): if m2p: message = m2p(message) decoded = None if on_m else message.decode() - except Exception, exc: + except Exception as exc: if not self.on_decode_error: raise self.on_decode_error(message, exc) diff --git a/kombu/mixins.py b/kombu/mixins.py index 8ee34f2e..2f9e5258 100644 --- a/kombu/mixins.py +++ b/kombu/mixins.py @@ -9,7 +9,6 @@ Useful mixin classes. """ from __future__ import absolute_import -from __future__ import with_statement import socket diff --git a/kombu/pidbox.py b/kombu/pidbox.py index ee3c89ca..3a6f3c8d 100644 --- a/kombu/pidbox.py +++ b/kombu/pidbox.py @@ -9,7 +9,6 @@ Generic process mailbox. """ from __future__ import absolute_import -from __future__ import with_statement import socket @@ -83,7 +82,7 @@ class Node(object): reply = handle(method, kwdict(arguments)) except SystemExit: raise - except Exception, exc: + except Exception as exc: reply = {'error': repr(exc)} if reply_to: diff --git a/kombu/tests/test_common.py b/kombu/tests/test_common.py index 18f4381b..b88a4a71 100644 --- a/kombu/tests/test_common.py +++ b/kombu/tests/test_common.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement import socket diff --git a/kombu/tests/test_compat.py b/kombu/tests/test_compat.py index 36a60d39..2a6bd873 100644 --- a/kombu/tests/test_compat.py +++ b/kombu/tests/test_compat.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement from mock import patch diff --git a/kombu/tests/test_connection.py b/kombu/tests/test_connection.py index ae8a726f..c0817eec 100644 --- a/kombu/tests/test_connection.py +++ b/kombu/tests/test_connection.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement import pickle diff --git a/kombu/tests/test_entities.py b/kombu/tests/test_entities.py index 5650c724..cdd9c34a 100644 --- a/kombu/tests/test_entities.py +++ b/kombu/tests/test_entities.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement from kombu import Connection from kombu.entity import Exchange, Queue diff --git a/kombu/tests/test_messaging.py b/kombu/tests/test_messaging.py index bb9f4610..66d3d8b8 100644 --- a/kombu/tests/test_messaging.py +++ b/kombu/tests/test_messaging.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement import anyjson diff --git a/kombu/tests/test_pidbox.py b/kombu/tests/test_pidbox.py index 33e071a7..b83227b7 100644 --- a/kombu/tests/test_pidbox.py +++ b/kombu/tests/test_pidbox.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement import socket diff --git a/kombu/tests/test_pools.py b/kombu/tests/test_pools.py index ce11f584..0c667f8e 100644 --- a/kombu/tests/test_pools.py +++ b/kombu/tests/test_pools.py @@ -1,4 +1,4 @@ -from __future__ import with_statement +from __future__ import absolute_import from kombu import Connection from kombu import pools diff --git a/kombu/tests/test_serialization.py b/kombu/tests/test_serialization.py index c4b8bd81..fba576ad 100644 --- a/kombu/tests/test_serialization.py +++ b/kombu/tests/test_serialization.py @@ -1,7 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- from __future__ import absolute_import -from __future__ import with_statement import sys diff --git a/kombu/tests/test_simple.py b/kombu/tests/test_simple.py index 26b09080..4cf4db42 100644 --- a/kombu/tests/test_simple.py +++ b/kombu/tests/test_simple.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement from Queue import Empty diff --git a/kombu/tests/transport/test_base.py b/kombu/tests/transport/test_base.py index e369449f..ce83f23f 100644 --- a/kombu/tests/transport/test_base.py +++ b/kombu/tests/transport/test_base.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement from kombu import Connection, Consumer, Producer, Queue from kombu.transport.base import Message, StdChannel, Transport diff --git a/kombu/tests/transport/test_filesystem.py b/kombu/tests/transport/test_filesystem.py index 7d004b2a..6a8d64d1 100644 --- a/kombu/tests/transport/test_filesystem.py +++ b/kombu/tests/transport/test_filesystem.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement import tempfile diff --git a/kombu/tests/transport/test_memory.py b/kombu/tests/transport/test_memory.py index 306a9e02..95e3432e 100644 --- a/kombu/tests/transport/test_memory.py +++ b/kombu/tests/transport/test_memory.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement import socket diff --git a/kombu/tests/transport/test_redis.py b/kombu/tests/transport/test_redis.py index 34dba4bd..52cfb61d 100644 --- a/kombu/tests/transport/test_redis.py +++ b/kombu/tests/transport/test_redis.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement import socket import types diff --git a/kombu/tests/transport/test_sqlalchemy.py b/kombu/tests/transport/test_sqlalchemy.py index 1f8e1b01..82b51ebc 100644 --- a/kombu/tests/transport/test_sqlalchemy.py +++ b/kombu/tests/transport/test_sqlalchemy.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement from mock import patch from nose import SkipTest diff --git a/kombu/tests/transport/test_transport.py b/kombu/tests/transport/test_transport.py index 11cdcbe3..608b9767 100644 --- a/kombu/tests/transport/test_transport.py +++ b/kombu/tests/transport/test_transport.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement from mock import patch diff --git a/kombu/tests/transport/virtual/test_base.py b/kombu/tests/transport/virtual/test_base.py index af716ede..7e58079d 100644 --- a/kombu/tests/transport/virtual/test_base.py +++ b/kombu/tests/transport/virtual/test_base.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement import warnings @@ -350,7 +349,7 @@ class test_Channel(TestCase): exc = None try: raise KeyError() - except KeyError, exc_: + except KeyError as exc_: exc = exc_ ru.return_value = [(exc, 1)] diff --git a/kombu/tests/transport/virtual/test_exchange.py b/kombu/tests/transport/virtual/test_exchange.py index d1b2a85a..0f4d42d7 100644 --- a/kombu/tests/transport/virtual/test_exchange.py +++ b/kombu/tests/transport/virtual/test_exchange.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement from kombu import Connection from kombu.transport.virtual import exchange diff --git a/kombu/tests/transport/virtual/test_scheduling.py b/kombu/tests/transport/virtual/test_scheduling.py index afbcd061..2a6d19dd 100644 --- a/kombu/tests/transport/virtual/test_scheduling.py +++ b/kombu/tests/transport/virtual/test_scheduling.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from __future__ import with_statement from kombu.transport.virtual.scheduling import FairCycle diff --git a/kombu/tests/utilities/test_encoding.py b/kombu/tests/utilities/test_encoding.py index eb19d1ad..9fe181e9 100644 --- a/kombu/tests/utilities/test_encoding.py +++ b/kombu/tests/utilities/test_encoding.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import -from __future__ import with_statement import sys diff --git a/kombu/transport/SQS.py b/kombu/transport/SQS.py index 185791e5..b2d6edab 100644 --- a/kombu/transport/SQS.py +++ b/kombu/transport/SQS.py @@ -274,7 +274,7 @@ class Channel(virtual.Channel): if conn: try: conn.close() - except AttributeError, exc: # FIXME ??? + except AttributeError as exc: # FIXME ??? if "can't set attribute" not in str(exc): raise diff --git a/kombu/transport/amqplib.py b/kombu/transport/amqplib.py index f0fb2de4..f5125be2 100644 --- a/kombu/transport/amqplib.py +++ b/kombu/transport/amqplib.py @@ -58,7 +58,7 @@ class TCPTransport(transport.TCPTransport): while len(self._read_buffer) < n: try: s = self.sock.recv(65536) - except socket.error, exc: + except socket.error as exc: if not initial and exc.errno in (errno.EAGAIN, errno.EINTR): continue raise @@ -107,7 +107,7 @@ class SSLTransport(transport.SSLTransport): while len(result) < n: try: s = self.sslobj.read(n - len(result)) - except socket.error, exc: + except socket.error as exc: if not initial and exc.errno in (errno.EAGAIN, errno.EINTR): continue raise @@ -191,7 +191,7 @@ class Connection(amqp.Connection): # pragma: no cover try: try: return self.method_reader.read_method() - except SSLError, exc: + except SSLError as exc: # http://bugs.python.org/issue10272 if 'timed out' in str(exc): raise socket.timeout() diff --git a/kombu/transport/base.py b/kombu/transport/base.py index fa3706c4..5a5bcb35 100644 --- a/kombu/transport/base.py +++ b/kombu/transport/base.py @@ -100,14 +100,14 @@ class Message(object): def ack_log_error(self, logger, errors): try: self.ack() - except errors, exc: + except errors as exc: logger.critical("Couldn't ack %r, reason:%r", self.delivery_tag, exc, exc_info=True) def reject_log_error(self, logger, errors): try: self.reject() - except errors, exc: + except errors as exc: logger.critical("Couldn't ack %r, reason: %r", self.delivery_tag, exc, exc_info=True) diff --git a/kombu/transport/mongodb.py b/kombu/transport/mongodb.py index 118de06c..064c71cb 100644 --- a/kombu/transport/mongodb.py +++ b/kombu/transport/mongodb.py @@ -56,7 +56,7 @@ class Channel(virtual.Channel): msg = self.client.command('findandmodify', 'messages', query={'queue': queue}, sort={'_id': pymongo.ASCENDING}, remove=True) - except errors.OperationFailure, exc: + except errors.OperationFailure as exc: if 'No matching object found' in exc.args[0]: raise Empty() raise diff --git a/kombu/transport/redis.py b/kombu/transport/redis.py index 98827578..067ef234 100644 --- a/kombu/transport/redis.py +++ b/kombu/transport/redis.py @@ -9,7 +9,6 @@ Redis transport. """ from __future__ import absolute_import -from __future__ import with_statement from bisect import bisect from contextlib import contextmanager diff --git a/kombu/transport/virtual/__init__.py b/kombu/transport/virtual/__init__.py index 68f2df38..620e9a7f 100644 --- a/kombu/transport/virtual/__init__.py +++ b/kombu/transport/virtual/__init__.py @@ -164,7 +164,7 @@ class QoS(object): try: self.channel._restore(message) - except BaseException, exc: + except BaseException as exc: errors.append((exc, message)) delivered.clear() return errors diff --git a/kombu/transport/zmq.py b/kombu/transport/zmq.py index d17d94d7..8a6a85dd 100644 --- a/kombu/transport/zmq.py +++ b/kombu/transport/zmq.py @@ -125,9 +125,9 @@ class Client(object): def get(self, queue=None, timeout=None): try: return self.sink.recv(flags=zmq.NOBLOCK) - except zmq.ZMQError, e: - if e.errno == zmq.EAGAIN: - raise socket.error(errno.EAGAIN, e.strerror) + except zmq.ZMQError as exc: + if exc.errno == zmq.EAGAIN: + raise socket.error(errno.EAGAIN, exc.strerror) else: raise @@ -174,7 +174,7 @@ class Channel(virtual.Channel): def _get(self, queue, timeout=None): try: return loads(self.client.get(queue, timeout)) - except socket.error, exc: + except socket.error as exc: if exc.errno == errno.EAGAIN and timeout != 0: raise Empty() else: @@ -255,8 +255,8 @@ class Transport(virtual.Transport): for channel in connection.channels: try: evt = channel.cycle.get(timeout=timeout) - except socket.error, e: - if e.errno == errno.EAGAIN: + except socket.error as exc: + if exc.errno == errno.EAGAIN: continue raise else: diff --git a/kombu/utils/__init__.py b/kombu/utils/__init__.py index 6ebbaa01..52a50bb6 100644 --- a/kombu/utils/__init__.py +++ b/kombu/utils/__init__.py @@ -81,7 +81,7 @@ def symbol_by_name(name, aliases={}, imp=None, package=None, try: try: module = imp(module_name, package=package, **kwargs) - except ValueError, exc: + except ValueError as exc: raise ValueError, ValueError( "Couldn't import %r: %s" % (name, exc)), sys.exc_info()[2] return getattr(module, cls_name) if cls_name else module @@ -218,7 +218,7 @@ def retry_over_time(fun, catch, args=[], kwargs={}, errback=None, for retries in count(): try: return fun(*args, **kwargs) - except catch, exc: + except catch as exc: if max_retries is not None and retries > max_retries: raise if callback: @@ -244,7 +244,7 @@ def emergency_dump_state(state, open_file=open, dump=None): try: try: dump(state, fh, protocol=0) - except Exception, exc: + except Exception as exc: say('Cannot pickle state: %r. Fallback to pformat.' % (exc, )) fh.write(pformat(state)) finally: diff --git a/kombu/utils/encoding.py b/kombu/utils/encoding.py index f589b9e6..298edcad 100644 --- a/kombu/utils/encoding.py +++ b/kombu/utils/encoding.py @@ -91,7 +91,7 @@ def _safe_str(s, errors='replace'): return s try: return str(s) - except Exception, exc: + except Exception as exc: return '<Unrepresentable %r: %r %r>' % ( type(s), exc, '\n'.join(traceback.format_stack())) encoding = default_encoding() @@ -99,7 +99,7 @@ def _safe_str(s, errors='replace'): if isinstance(s, unicode): return s.encode(encoding, errors) return unicode(s, encoding, errors) - except Exception, exc: + except Exception as exc: return '<Unrepresentable %r: %r %r>' % ( type(s), exc, '\n'.join(traceback.format_stack())) diff --git a/kombu/utils/eventio.py b/kombu/utils/eventio.py index 5eff766b..63c6eb66 100644 --- a/kombu/utils/eventio.py +++ b/kombu/utils/eventio.py @@ -73,7 +73,7 @@ class Poller(object): def poll(self, timeout): try: return self._poll(timeout) - except Exception, exc: + except Exception as exc: if get_errno(exc) != errno.EINTR: raise @@ -86,7 +86,7 @@ class _epoll(Poller): def register(self, fd, events): try: self._epoll.register(fd, events) - except Exception, exc: + except Exception as exc: if get_errno(exc) != errno.EEXIST: raise @@ -97,7 +97,7 @@ class _epoll(Poller): pass except ValueError: pass - except IOError, exc: + except IOError as exc: if get_errno(exc) != errno.ENOENT: raise diff --git a/pavement.py b/pavement.py index a51cca73..0a9e92a1 100644 --- a/pavement.py +++ b/pavement.py @@ -4,15 +4,15 @@ from paver.easy import * # noqa from paver import doctools # noqa from paver.setuputils import setup # noqa -PYCOMPILE_CACHES = ["*.pyc", "*$py.class"] +PYCOMPILE_CACHES = ['*.pyc', '*$py.class'] options( - sphinx=Bunch(builddir=".build"), + sphinx=Bunch(builddir='.build'), ) def sphinx_builddir(options): - return path("docs") / options.sphinx.builddir / "html" + return path('docs') / options.sphinx.builddir / 'html' @task @@ -21,24 +21,24 @@ def clean_docs(options): @task -@needs("clean_docs", "paver.doctools.html") +@needs('clean_docs', 'paver.doctools.html') def html(options): - destdir = path("Documentation") + destdir = path('Documentation') destdir.rmtree() builtdocs = sphinx_builddir(options) builtdocs.move(destdir) @task -@needs("paver.doctools.html") +@needs('paver.doctools.html') def qhtml(options): - destdir = path("Documentation") + destdir = path('Documentation') builtdocs = sphinx_builddir(options) - sh("rsync -az %s/ %s" % (builtdocs, destdir)) + sh('rsync -az %s/ %s' % (builtdocs, destdir)) @task -@needs("clean_docs", "paver.doctools.html") +@needs('clean_docs', 'paver.doctools.html') def ghdocs(options): builtdocs = sphinx_builddir(options) sh("git checkout gh-pages && \ @@ -49,79 +49,79 @@ def ghdocs(options): @task -@needs("clean_docs", "paver.doctools.html") +@needs('clean_docs', 'paver.doctools.html') def upload_pypi_docs(options): - builtdocs = path("docs") / options.builddir / "html" + builtdocs = path('docs') / options.builddir / 'html' sh("python setup.py upload_sphinx --upload-dir='%s'" % (builtdocs)) @task -@needs("upload_pypi_docs", "ghdocs") +@needs('upload_pypi_docs', 'ghdocs') def upload_docs(options): pass @task def autodoc(options): - sh("extra/release/doc4allmods kombu") + sh('extra/release/doc4allmods kombu') @task def verifyindex(options): - sh("extra/release/verify-reference-index.sh") + sh('extra/release/verify-reference-index.sh') @task def clean_readme(options): - path("README").unlink() - path("README.rst").unlink() + path('README').unlink() + path('README.rst').unlink() @task -@needs("clean_readme") +@needs('clean_readme') def readme(options): - sh("python extra/release/sphinx-to-rst.py docs/templates/readme.txt \ - > README.rst") - sh("ln -sf README.rst README") + sh('python extra/release/sphinx-to-rst.py docs/templates/readme.txt \ + > README.rst') + sh('ln -sf README.rst README') @task @cmdopts([ - ("custom=", "C", "custom version"), + ('custom=', 'C', 'custom version'), ]) def bump(options): s = "-- '%s'" % (options.custom, ) \ - if getattr(options, "custom", None) else "" - sh("extra/release/bump_version.py \ - kombu/__init__.py README.rst %s" % (s, )) + if getattr(options, 'custom', None) else '' + sh('extra/release/bump_version.py \ + kombu/__init__.py README.rst %s' % (s, )) @task @cmdopts([ - ("coverage", "c", "Enable coverage"), - ("quick", "q", "Quick test"), - ("verbose", "V", "Make more noise"), + ('coverage', 'c', 'Enable coverage'), + ('quick', 'q', 'Quick test'), + ('verbose', 'V', 'Make more noise'), ]) def test(options): - cmd = "nosetests" - if getattr(options, "coverage", False): - cmd += " --with-coverage3" - if getattr(options, "quick", False): - cmd = "QUICKTEST=1 SKIP_RLIMITS=1 %s" % cmd - if getattr(options, "verbose", False): - cmd += " --verbosity=2" + cmd = 'nosetests' + if getattr(options, 'coverage', False): + cmd += ' --with-coverage3' + if getattr(options, 'quick', False): + cmd = 'QUICKTEST=1 SKIP_RLIMITS=1 %s' % cmd + if getattr(options, 'verbose', False): + cmd += ' --verbosity=2' sh(cmd) @task @cmdopts([ - ("noerror", "E", "Ignore errors"), + ('noerror', 'E', 'Ignore errors'), ]) def flake8(options): - noerror = getattr(options, "noerror", False) - complexity = getattr(options, "complexity", 22) - migrations_path = os.path.join("kombu", "transport", "django", - "migrations", "0.+?\.py") + noerror = getattr(options, 'noerror', False) + complexity = getattr(options, 'complexity', 22) + migrations_path = os.path.join('kombu', 'transport', 'django', + 'migrations', '0.+?\.py') sh("""flake8 kombu | perl -mstrict -mwarnings -nle' my $ignore = (m/too complex \((\d+)\)/ && $1 le %s) || (m{^%s}); @@ -131,17 +131,17 @@ def flake8(options): @task @cmdopts([ - ("noerror", "E", "Ignore errors"), + ('noerror', 'E', 'Ignore errors'), ]) def flakeplus(options): - noerror = getattr(options, "noerror", False) - sh("python extra/release/flakeplus.py kombu", + noerror = getattr(options, 'noerror', False) + sh('flakeplus kombu --2.6', ignore_error=noerror) @task @cmdopts([ - ("noerror", "E", "Ignore errors"), + ('noerror', 'E', 'Ignore errors'), ]) def flakes(options): flake8(options) @@ -150,39 +150,39 @@ def flakes(options): @task @cmdopts([ - ("noerror", "E", "Ignore errors"), + ('noerror', 'E', 'Ignore errors'), ]) def pep8(options): - noerror = getattr(options, "noerror", False) + noerror = getattr(options, 'noerror', False) return sh("""find kombu -name "*.py" | xargs pep8 | perl -nle'\ print; $a=1 if $_}{exit($a)'""", ignore_error=noerror) @task def removepyc(options): - sh("find . -type f -a \\( %s \\) | xargs rm" % ( - " -o ".join("-name '%s'" % (pat, ) for pat in PYCOMPILE_CACHES), )) + sh('find . -type f -a \\( %s \\) | xargs rm' % ( + ' -o '.join("-name '%s'" % (pat, ) for pat in PYCOMPILE_CACHES), )) @task -@needs("removepyc") +@needs('removepyc') def gitclean(options): - sh("git clean -xdn") + sh('git clean -xdn') @task -@needs("removepyc") +@needs('removepyc') def gitcleanforce(options): - sh("git clean -xdf") + sh('git clean -xdf') @task -@needs("flakes", "autodoc", "verifyindex", "test", "gitclean") +@needs('flakes', 'autodoc', 'verifyindex', 'test', 'gitclean') def releaseok(options): pass @task -@needs("releaseok", "removepyc", "upload_docs") +@needs('releaseok', 'removepyc', 'upload_docs') def release(options): pass |