Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

flakes

  • Loading branch information...
commit f03ba7477331a0189347e38325c440132c434aa1 1 parent 75bf573
@ask ask authored
View
6 amqp/connection.py
@@ -862,7 +862,8 @@ def _tune(self, args):
self.method_writer.frame_max = self.frame_max
self.server_heartbeat = args.read_short()
- # negotiate the heartbeat interval to the smaller of the specified values
+ # negotiate the heartbeat interval to the smaller of the
+ # specified values
if self.server_heartbeat == 0 or self.client_heartbeat == 0:
self.heartbeat = max(self.server_heartbeat, self.client_heartbeat)
else:
@@ -900,7 +901,8 @@ def heartbeat_tick(self, rate=2):
# if we've missed two intervals' heartbeats, fail; this gives the
# server enough time to send heartbeats a little late
if (self.last_heartbeat_received and
- self.last_heartbeat_received + 2 * self.heartbeat < monotonic()):
+ self.last_heartbeat_received + 2 *
+ self.heartbeat < monotonic()):
raise ConnectionForced('Too many heartbeats missed')
def _x_tune_ok(self, channel_max, frame_max, heartbeat):
View
1  amqp/five.py
@@ -186,4 +186,3 @@ def _monotonic(): # noqa
from time import monotonic
except ImportError:
monotonic = _monotonic # noqa
-
View
2  amqp/serialization.py
@@ -347,7 +347,7 @@ def write_item(self, v, k=None):
elif isinstance(v, (list, tuple)):
self.write(b'A')
self.write_array(v)
- elif v == None:
+ elif v is None:
self.write(b'V')
else:
err = (ILLEGAL_TABLE_TYPE_WITH_KEY.format(type(v), k, v) if k
View
1  amqp/transport.py
@@ -18,6 +18,7 @@
import errno
import re
import socket
+import ssl
# Jython does not have this attribute
try:
View
17 demo/amqp_clock.py
@@ -27,18 +27,23 @@
def main():
parser = OptionParser()
- parser.add_option('--host', dest='host',
- help='AMQP server to connect to (default: %default)',
- default='localhost')
- parser.add_option('-u', '--userid', dest='userid',
+ parser.add_option(
+ '--host', dest='host',
+ help='AMQP server to connect to (default: %default)',
+ default='localhost',
+ )
+ parser.add_option(
+ '-u', '--userid', dest='userid',
help='AMQP userid to authenticate as (default: %default)',
default='guest',
)
- parser.add_option('-p', '--password', dest='password',
+ parser.add_option(
+ '-p', '--password', dest='password',
help='AMQP password to authenticate with (default: %default)',
default='guest',
)
- parser.add_option('--ssl', dest='ssl', action='store_true',
+ parser.add_option(
+ '--ssl', dest='ssl', action='store_true',
help='Enable SSL with AMQP server (default: not enabled)',
default=False,
)
View
24 demo/demo_receive.py
@@ -16,14 +16,14 @@
def callback(channel, msg):
for key, val in msg.properties.items():
- print ('%s: %s' % (key, str(val)))
+ print('%s: %s' % (key, str(val)))
for key, val in msg.delivery_info.items():
- print ('> %s: %s' % (key, str(val)))
+ print('> %s: %s' % (key, str(val)))
- print ('')
- print (msg.body)
- print ('-------')
- print msg.delivery_tag
+ print('')
+ print(msg.body)
+ print('-------')
+ print(msg.delivery_tag)
channel.basic_ack(msg.delivery_tag)
#
@@ -35,19 +35,23 @@ def callback(channel, msg):
def main():
parser = OptionParser()
- parser.add_option('--host', dest='host',
+ parser.add_option(
+ '--host', dest='host',
help='AMQP server to connect to (default: %default)',
default='localhost',
)
- parser.add_option('-u', '--userid', dest='userid',
+ parser.add_option(
+ '-u', '--userid', dest='userid',
help='userid to authenticate as (default: %default)',
default='guest',
)
- parser.add_option('-p', '--password', dest='password',
+ parser.add_option(
+ '-p', '--password', dest='password',
help='password to authenticate with (default: %default)',
default='guest',
)
- parser.add_option('--ssl', dest='ssl', action='store_true',
+ parser.add_option(
+ '--ssl', dest='ssl', action='store_true',
help='Enable SSL (default: not enabled)',
default=False,
)
View
12 demo/demo_send.py
@@ -19,19 +19,23 @@ def main():
parser = OptionParser(
usage='usage: %prog [options] message\nexample: %prog hello world',
)
- parser.add_option('--host', dest='host',
+ parser.add_option(
+ '--host', dest='host',
help='AMQP server to connect to (default: %default)',
default='localhost',
)
- parser.add_option('-u', '--userid', dest='userid',
+ parser.add_option(
+ '-u', '--userid', dest='userid',
help='userid to authenticate as (default: %default)',
default='guest',
)
- parser.add_option('-p', '--password', dest='password',
+ parser.add_option(
+ '-p', '--password', dest='password',
help='password to authenticate with (default: %default)',
default='guest',
)
- parser.add_option('--ssl', dest='ssl', action='store_true',
+ parser.add_option(
+ '--ssl', dest='ssl', action='store_true',
help='Enable SSL (default: not enabled)',
default=False,
)
View
4 docs/_ext/applyxrefs.py
@@ -6,8 +6,8 @@
testing = False
DONT_TOUCH = (
- './index.txt',
- )
+ './index.txt',
+)
def target_name(fn):
View
4 docs/_ext/literals_to_xrefs.py
@@ -95,8 +95,8 @@ def fixliterals(fname):
replace_type in ("class", "func", "meth"):
default = default[:-2]
replace_value = raw_input(
- colorize("Text <target> [", fg="yellow") + default + \
- colorize("]: ", fg="yellow")).strip()
+ colorize("Text <target> [", fg="yellow") + default +
+ colorize("]: ", fg="yellow")).strip()
if not replace_value:
replace_value = default
new.append(":%s:`%s`" % (replace_type, replace_value))
View
6 docs/conf.py
@@ -70,8 +70,8 @@
html_use_index = True
latex_documents = [
- ('index', 'py-amqp.tex', ur'py-amqp Documentation',
- ur'Ask Solem & Contributors', 'manual'),
+ ('index', 'py-amqp.tex', ur'py-amqp Documentation',
+ ur'Ask Solem & Contributors', 'manual'),
]
html_theme = "celery"
@@ -89,7 +89,7 @@
issuetracker_project = "celery/py-amqp"
issuetracker_issue_pattern = r'[Ii]ssue #(\d+)'
-# -- Options for Epub output ---------------------------------------------------
+# -- Options for Epub output ------------------------------------------------
# Bibliographic Dublin Core info.
epub_title = 'py-amqp Manual, Version 1.0'
View
17 extra/generate_skeleton_0_8.py
@@ -204,9 +204,10 @@ def generate_methods(class_element, out):
if 'content' in amqp_method.attrib:
params.append('msg')
- out.write(' def %s(%s):\n' %
- (_fixup_method_name(class_element, amqp_method),
- ', '.join(params + fieldnames)))
+ out.write(' def %s(%s):\n' % (
+ _fixup_method_name(class_element, amqp_method),
+ ', '.join(params + fieldnames)),
+ )
s = generate_docstr(amqp_method, ' ', ' """')
if s:
@@ -231,7 +232,7 @@ def generate_methods(class_element, out):
if 'synchronous' in amqp_method.attrib:
responses = [x.attrib['name']
- for x in amqp_method.findall('response')]
+ for x in amqp_method.findall('response')]
out.write(' return self.wait(allowed_methods=[\n')
for r in responses:
resp = method_name_map[(class_element.attrib['name'], r)]
@@ -274,7 +275,7 @@ def generate_class(spec, class_element, out):
#
for amqp_class in spec.findall('class'):
if (amqp_class.attrib['handler'] == class_element.attrib['name']) and \
- (amqp_class.attrib['name'] != class_element.attrib['name']):
+ (amqp_class.attrib['name'] != class_element.attrib['name']):
out.write(' #############\n')
out.write(' #\n')
out.write(' # %s\n' % amqp_class.attrib['name'].capitalize())
@@ -315,8 +316,8 @@ def generate_module(spec, out):
(
amqp_class.attrib['index'],
amqp_method.attrib['index'],
- amqp_class.attrib['handler'].capitalize() + '.' +
- _fixup_method_name(amqp_class, amqp_method),
+ (amqp_class.attrib['handler'].capitalize() + '.' +
+ _fixup_method_name(amqp_class, amqp_method)),
)
#### Actually generate output
@@ -335,7 +336,7 @@ def generate_module(spec, out):
# for chassis in amqp_method.findall('chassis'):
# print ' ', chassis.attrib
chassis = [x.attrib['name']
- for x in amqp_method.findall('chassis')]
+ for x in amqp_method.findall('chassis')]
if 'client' in chassis:
out.write(" (%s, %s): (%s, %s._%s),\n" % (
amqp_class.attrib['index'],
View
14 funtests/test_channel.py
@@ -166,8 +166,8 @@ def test_survives_channel_error(self):
self.ch.queue_declare('krjqheewq_bogus', passive=True)
self.ch.queue_declare('funtest_survive')
self.ch.queue_declare('funtest_survive', passive=True)
- self.assertEqual(0,
- self.ch.queue_delete('funtest_survive'),
+ self.assertEqual(
+ 0, self.ch.queue_delete('funtest_survive'),
)
def test_invalid_header(self):
@@ -273,9 +273,9 @@ def test_exchange_bind(self):
self.ch.exchange_declare(source_exchange, 'topic', auto_delete=True)
qname, _, _ = self.ch.queue_declare()
- self.ch.exchange_bind(destination = dest_exchange,
- source = source_exchange,
- routing_key = test_routing_key)
+ self.ch.exchange_bind(destination=dest_exchange,
+ source=source_exchange,
+ routing_key=test_routing_key)
self.ch.queue_bind(qname, dest_exchange,
routing_key=test_routing_key)
@@ -284,9 +284,8 @@ def test_exchange_bind(self):
content_type='text/plain',
application_headers={'foo': 7, 'bar': 'baz'})
-
self.ch.basic_publish(msg, source_exchange,
- routing_key = test_routing_key)
+ routing_key=test_routing_key)
msg2 = self.ch.basic_get(qname, no_ack=True)
self.assertEqual(msg, msg2)
@@ -309,6 +308,7 @@ def test_exchange_unbind(self):
source=source_exchange,
routing_key=test_routing_key)
+
def main():
suite = unittest.TestLoader().loadTestsFromTestCase(TestChannel)
unittest.TextTestRunner(**settings.test_args).run(suite)
View
2  funtests/test_serialization.py
@@ -321,7 +321,7 @@ def test_table_multi(self):
'baz': 'this is some random string I typed',
'ubaz': u'And something in unicode',
'dday_aniv': datetime(1994, 6, 6),
- 'nothing' : None,
+ 'nothing': None,
'more': {
'abc': -123,
'def': 'hello world',
View
123 pavement.py
@@ -1,13 +1,11 @@
-import os
-import sys
-from paver.easy import *
-from paver import doctools
-from paver.setuputils import setup
-sys.path.insert(0, os.path.abspath('.'))
+from paver.easy import * # noqa
+from paver import doctools # noqa
+from paver.setuputils import setup # noqa
+
PYCOMPILE_CACHES = ['*.pyc', '*$py.class']
options(
- sphinx=Bunch(builddir='.build'),
+ sphinx=Bunch(builddir='.build'),
)
@@ -34,7 +32,7 @@ def html(options):
def qhtml(options):
destdir = path('Documentation')
builtdocs = sphinx_builddir(options)
- sh('rsync -az {0}/ {1}'.format(builtdocs, destdir))
+ sh('rsync -az %s/ %s' % (builtdocs, destdir))
@task
@@ -42,18 +40,17 @@ def qhtml(options):
def ghdocs(options):
builtdocs = sphinx_builddir(options)
sh("git checkout gh-pages && \
- cp -r {0}/* . && \
+ cp -r %s/* . && \
git commit . -m 'Rendered documentation for Github Pages.' && \
git push origin gh-pages && \
- git checkout master".format(builtdocs))
+ git checkout master" % builtdocs)
@task
@needs('clean_docs', 'paver.doctools.html')
def upload_pypi_docs(options):
builtdocs = path('docs') / options.builddir / 'html'
- sh("{0} setup.py upload_sphinx --upload-dir='{1}'".format(
- sys.executable, builtdocs))
+ sh("python setup.py upload_sphinx --upload-dir='%s'" % (builtdocs))
@task
@@ -73,38 +70,6 @@ def verifyindex(options):
@task
-@cmdopts([
- ('noerror', 'E', 'Ignore errors'),
-])
-def flake8(options):
- noerror = getattr(options, 'noerror', False)
- complexity = getattr(options, 'complexity', 22)
- sh("""flake8 amqp | perl -mstrict -mwarnings -nle'
- my $ignore = m/too complex \((\d+)\)/ && $1 le {0};
- if (! $ignore) {{ print STDERR; our $FOUND_FLAKE = 1 }}
- }}{{exit $FOUND_FLAKE;
- '""".format(complexity), ignore_error=noerror)
-
-
-@task
-@cmdopts([
- ('noerror', 'E', 'Ignore errors'),
-])
-def flakeplus(options):
- noerror = getattr(options, 'noerror', False)
- sh('flakeplus amqp', ignore_error=noerror)
-
-
-@task
-@cmdopts([
- ('noerror', 'E', 'Ignore errors')
-])
-def flakes(options):
- flake8(options)
- flakeplus(options)
-
-
-@task
def clean_readme(options):
path('README').unlink()
path('README.rst').unlink()
@@ -113,15 +78,21 @@ def clean_readme(options):
@task
@needs('clean_readme')
def readme(options):
- sh('{0} extra/release/sphinx-to-rst.py docs/templates/readme.txt \
- > README.rst'.format(sys.executable))
+ 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'),
+])
def bump(options):
- sh("extra/release/bump_version.py \
- amqp/__init__.py docs/includes/intro.txt \
- --before-commit='paver readme'")
+ s = ("-- '%s'" % (options.custom, ) if getattr(options, 'custom', None)
+ else '')
+ sh('extra/release/bump_version.py \
+ amqp/__init__.py README.rst %s' % (s, ))
+
@task
@cmdopts([
@@ -133,6 +104,8 @@ 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'
sh(cmd)
@@ -142,18 +115,52 @@ def test(options):
@cmdopts([
('noerror', 'E', 'Ignore errors'),
])
+def flake8(options):
+ noerror = getattr(options, 'noerror', False)
+ complexity = getattr(options, 'complexity', 22)
+ sh("""flake8 amqp | perl -mstrict -mwarnings -nle'
+ my $ignore = (m/too complex \((\d+)\)/ && $1 le %s);
+ if (! $ignore) { print STDERR; our $FOUND_FLAKE = 1 }
+ }{exit $FOUND_FLAKE;
+ '""" % (complexity, ), ignore_error=noerror)
+
+
+@task
+@cmdopts([
+ ('noerror', 'E', 'Ignore errors'),
+])
+def flakeplus(options):
+ noerror = getattr(options, 'noerror', False)
+ sh('flakeplus amqp --2.6',
+ ignore_error=noerror)
+
+
+@task
+@cmdopts([
+ ('noerror', 'E', 'Ignore errors'),
+])
+def flakes(options):
+ flake8(options)
+ flakeplus(options)
+
+
+@task
+@cmdopts([
+ ('noerror', 'E', 'Ignore errors'),
+])
def pep8(options):
noerror = getattr(options, 'noerror', False)
- return sh("""find . -name "*.py" | xargs pep8 | perl -nle'\
+ return sh("""find amqp -name "*.py" | xargs pep8 | perl -nle'\
print; $a=1 if $_}{exit($a)'""", ignore_error=noerror)
@task
def removepyc(options):
- sh('find . -type f -a \\( {0} \\) | xargs rm'.format(
- ' -o '.join("-name '{0}'".format(pat) for pat in PYCOMPILE_CACHES)))
+ sh('find . -type f -a \\( %s \\) | xargs rm' % (
+ ' -o '.join("-name '%s'" % (pat, ) for pat in PYCOMPILE_CACHES), ))
sh('find . -type d -name "__pycache__" | xargs rm -r')
+
@task
@needs('removepyc')
def gitclean(options):
@@ -167,7 +174,7 @@ def gitcleanforce(options):
@task
-@needs('flakes', 'autodoc', 'verifyindex', 'gitclean')
+@needs('flakes', 'autodoc', 'verifyindex', 'test', 'gitclean')
def releaseok(options):
pass
@@ -176,13 +183,3 @@ def releaseok(options):
@needs('releaseok', 'removepyc', 'upload_docs')
def release(options):
pass
-
-
-@task
-def testloc(options):
- sh('sloccount tests')
-
-
-@task
-def loc(options):
- sh('sloccount amqp')
View
3  setup.py
@@ -35,7 +35,8 @@
Programming Language :: Python :: 3.1
Programming Language :: Python :: 3.2
Programming Language :: Python :: 3.3
- License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
+ License :: OSI Approved :: GNU Library or \
+Lesser General Public License (LGPL)
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Please sign in to comment.
Something went wrong with that request. Please try again.