aiowsgi_0.7.orig/.coveragerc0000644000000000000000000000045412500615255014316 0ustar 00000000000000[run] include = */aiowsgi/*.py omit = */docs* */tests* */examples* */lib_pypy* */lib/python* */lib-python* */site-packages* [report] exclude_lines = pragma: no cover def __repr__ raise NotImplementedError if __name__ == .__main__.: def parse_args aiowsgi_0.7.orig/.gitignore0000644000000000000000000000045612333034262014164 0ustar 00000000000000*~ *.bck bin build _build .bzr .bzrignore .chutifab .coverage coverage* develop-eggs dist downloads *.egg *.EGG *.egg-info *.EGG-INFO eggs fake-eggs .hg .hgignore .idea .installed.cfg *.jar *.mo .mr.developer.cfg nosetest* *.old *.orig parts *.pyc *.pyd *.pyo *.so src .svn *.swp .tox *.tmp* var *.wpr aiowsgi_0.7.orig/.travis.yml0000644000000000000000000000030212735156010014275 0ustar 00000000000000language: python python: 3.5 sudo: false install: - pip install tox coveralls script: - tox after_success: - coveralls env: - TOXENV=py27 - TOXENV=py33 - TOXENV=py34 - TOXENV=py35 aiowsgi_0.7.orig/CHANGES.rst0000644000000000000000000000077313367123625014012 0ustar 000000000000000.7 (2018-11-02) ================ - remove deprecated asyncio.async calls 0.6 (2016-06-30) ================ - Small changes to work with latest waitress release (force encoding data to utf8) 0.5 (2015-03-19) ================ - Use executor iif application is not a coroutine 0.4 (2015-03-13) ================ - Added thread.WSGIServer 0.3 (2014-06-19) ================ - Compat with latest trollius 0.2 (2014-05-10) ================ - Use waitress's tasks to parse request and send response aiowsgi_0.7.orig/LICENSE0000644000000000000000000000207213367122402013177 0ustar 00000000000000The MIT License (MIT) Copyright (c) 2016 Gael Pasgrimaud Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. aiowsgi_0.7.orig/MANIFEST.in0000644000000000000000000000027113367123620013732 0ustar 00000000000000graft docs prune docs/_build graft aiowsgi graft tests include .coveragerc LICENSE include *.py *.rst *.cfg *.ini exclude .installed.cfg global-exclude *.pyc global-exclude __pycache__ aiowsgi_0.7.orig/README.rst0000644000000000000000000000136213247320036013662 0ustar 00000000000000================================================ aiowsgi - minimalist wsgi server using asyncio ================================================ .. image:: https://travis-ci.org/gawel/aiowsgi.png?branch=master :target: https://travis-ci.org/gawel/aiowsgi .. image:: https://coveralls.io/repos/gawel/aiowsgi/badge.png?branch=master :target: https://coveralls.io/r/gawel/aiowsgi?branch=master .. image:: https://img.shields.io/pypi/v/aiowsgi.svg :target: https://crate.io/packages/aiowsgi/ .. image:: https://img.shields.io/pypi/dm/aiowsgi.svg :target: https://crate.io/packages/aiowsgi/ Require python 2.7, 3.3+ Source: https://github.com/gawel/aiowsgi/ Docs: https://aiowsgi.readthedocs.org/ You like it ? => https://www.gittip.com/gawel/ aiowsgi_0.7.orig/aiowsgi/0000755000000000000000000000000012333034262013631 5ustar 00000000000000aiowsgi_0.7.orig/bootstrap.py0000755000000000000000000001401612333034262014563 0ustar 00000000000000############################################################################## # # Copyright (c) 2006 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Bootstrap a buildout-based project Simply run this script in a directory containing a buildout.cfg. The script accepts buildout command-line options, so you can use the -c option to specify an alternate configuration file. """ import os import shutil import sys import tempfile from optparse import OptionParser tmpeggs = tempfile.mkdtemp() usage = '''\ [DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] Bootstraps a buildout-based project. Simply run this script in a directory containing a buildout.cfg, using the Python that you want bin/buildout to use. Note that by using --find-links to point to local resources, you can keep this script from going over the network. ''' parser = OptionParser(usage=usage) parser.add_option("-v", "--version", help="use a specific zc.buildout version") parser.add_option("-t", "--accept-buildout-test-releases", dest='accept_buildout_test_releases', action="store_true", default=False, help=("Normally, if you do not specify a --version, the " "bootstrap script and buildout gets the newest " "*final* versions of zc.buildout and its recipes and " "extensions for you. If you use this flag, " "bootstrap and buildout will get the newest releases " "even if they are alphas or betas.")) parser.add_option("-c", "--config-file", help=("Specify the path to the buildout configuration " "file to be used.")) parser.add_option("-f", "--find-links", help=("Specify a URL to search for buildout releases")) parser.add_option("--allow-site-packages", action="store_true", default=False, help=("Let bootstrap.py use existing site packages")) options, args = parser.parse_args() ###################################################################### # load/install setuptools try: if options.allow_site_packages: import setuptools import pkg_resources from urllib.request import urlopen except ImportError: from urllib2 import urlopen ez = {} exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) if not options.allow_site_packages: # ez_setup imports site, which adds site packages # this will remove them from the path to ensure that incompatible versions # of setuptools are not in the path import site # inside a virtualenv, there is no 'getsitepackages'. # We can't remove these reliably if hasattr(site, 'getsitepackages'): for sitepackage_path in site.getsitepackages(): sys.path[:] = [x for x in sys.path if sitepackage_path not in x] setup_args = dict(to_dir=tmpeggs, download_delay=0) ez['use_setuptools'](**setup_args) import setuptools import pkg_resources # This does not (always?) update the default working set. We will # do it. for path in sys.path: if path not in pkg_resources.working_set.entries: pkg_resources.working_set.add_entry(path) ###################################################################### # Install buildout ws = pkg_resources.working_set cmd = [sys.executable, '-c', 'from setuptools.command.easy_install import main; main()', '-mZqNxd', tmpeggs] find_links = os.environ.get( 'bootstrap-testing-find-links', options.find_links or ('http://downloads.buildout.org/' if options.accept_buildout_test_releases else None) ) if find_links: cmd.extend(['-f', find_links]) setuptools_path = ws.find( pkg_resources.Requirement.parse('setuptools')).location requirement = 'zc.buildout' version = options.version if version is None and not options.accept_buildout_test_releases: # Figure out the most recent final version of zc.buildout. import setuptools.package_index _final_parts = '*final-', '*final' def _final_version(parsed_version): for part in parsed_version: if (part[:1] == '*') and (part not in _final_parts): return False return True index = setuptools.package_index.PackageIndex( search_path=[setuptools_path]) if find_links: index.add_find_links((find_links,)) req = pkg_resources.Requirement.parse(requirement) if index.obtain(req) is not None: best = [] bestv = None for dist in index[req.project_name]: distv = dist.parsed_version if _final_version(distv): if bestv is None or distv > bestv: best = [dist] bestv = distv elif distv == bestv: best.append(dist) if best: best.sort() version = best[-1].version if version: requirement = '=='.join((requirement, version)) cmd.append(requirement) import subprocess if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0: raise Exception( "Failed to execute command:\n%s" % repr(cmd)[1:-1]) ###################################################################### # Import and run buildout ws.add_entry(tmpeggs) ws.require(requirement) import zc.buildout.buildout if not [a for a in args if '=' not in a]: args.append('bootstrap') # if -c was provided, we push it back into args for buildout' main function if options.config_file is not None: args[0:0] = ['-c', options.config_file] zc.buildout.buildout.main(args) shutil.rmtree(tmpeggs) aiowsgi_0.7.orig/buildout.cfg0000644000000000000000000000037612351010516014501 0ustar 00000000000000[buildout] newest = false extensions = gp.vcsdevelop parts = eggs develop = . [eggs] recipe = zc.recipe.egg eggs = Sphinx waitress aiowsgi [tests] recipe = zc.recipe.egg eggs = aiowsgi[test] dependent-scripts = true scripts = nosetests aiowsgi_0.7.orig/docs/0000755000000000000000000000000012333034262013117 5ustar 00000000000000aiowsgi_0.7.orig/setup.cfg0000644000000000000000000000022512735156010014011 0ustar 00000000000000[pytest] addopts = --doctest-modules --ignore=setup.py --ignore=bootstrap.py [aliases] dev = develop easy_install aiowsgi[test] aiowsgi_0.7.orig/setup.py0000644000000000000000000000305713367123625013720 0ustar 00000000000000# -*- coding: utf-8 -*- import os import sys from setuptools import setup from setuptools import find_packages version = '0.7' install_requires = ['waitress', 'webob'] test_requires = [ 'pytest', 'webtest', 'coverage', 'coveralls', 'WSGIProxy2', ] if sys.version_info[:2] < (3, 0): install_requires.extend([ 'trollius', 'futures', ]) test_requires.extend(['mock']) elif sys.version_info[:2] < (3, 3): install_requires.append('trollius') test_requires.append('mock') elif sys.version_info[:2] < (3, 4): install_requires.append('asyncio') def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() setup( name='aiowsgi', version=version, description="minimalist wsgi server using asyncio", long_description=read('README.rst'), classifiers=[ 'Intended Audience :: Developers', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'License :: OSI Approved :: MIT License', ], keywords='', author='Gael Pasgrimaud', author_email='gael@gawel.org', url='https://github.com/gawel/aiowsgi/', license='MIT', packages=find_packages(exclude=['docs', 'tests']), include_package_data=True, zip_safe=False, install_requires=install_requires, extras_require={ 'test': test_requires, }, entry_points=""" [paste.server_runner] main = aiowsgi:serve_paste [console_scripts] aiowsgi-serve = aiowsgi:run """, ) aiowsgi_0.7.orig/tests/0000755000000000000000000000000012333034262013331 5ustar 00000000000000aiowsgi_0.7.orig/tox.ini0000644000000000000000000000017713367123162013515 0ustar 00000000000000[tox] envlist = py27,py34,py35,py36 [testenv] skip_install = true commands = {envbindir}/py.test [] deps = -e .[test] aiowsgi_0.7.orig/aiowsgi/__init__.py0000644000000000000000000001017713367123162015756 0ustar 00000000000000# -*- coding: utf-8 -*- from __future__ import unicode_literals from __future__ import print_function from concurrent.futures import ThreadPoolExecutor from waitress.parser import HTTPRequestParser from waitress import utilities from .compat import asyncio from aiowsgi import task import waitress import sys class WSGIProtocol(asyncio.Protocol): request_class = HTTPRequestParser def connection_made(self, transport): self.transport = transport self.request = None def data_received(self, data): if self.request is None: request = self.request_class(self.adj) else: request = self.request pos = request.received(data) if self.request is None and len(data) > pos: request.received(data[pos:]) if request.completed or request.error: self.request = None task_class = task.ErrorTask if request.error else task.WSGITask channel = Channel(self.server, self.transport) t = task_class(channel, request) asyncio.ensure_future(asyncio.coroutine(t.service)(), loop=self.server.loop) if task_class is task.ErrorTask: channel.done.set_result(True) return channel else: self.request = request @classmethod def run(cls): cls.loop.run_forever() class Channel(object): def __init__(self, server, transport): self.loop = server.loop self.server = server self.transport = transport self.write = transport.write self.addr = transport.get_extra_info('peername')[0] self.done = asyncio.Future(loop=self.loop) def write_soon(self, data): if data: if 'Buffer' in data.__class__.__name__: for v in data: self.write(v) else: if not isinstance(data, bytes): data = data.encode('utf8') self.write(data) return len(data) return 0 def create_server(application, ssl=None, **adj): """Create a wsgi server: .. code-block:: >>> @asyncio.coroutine ... def application(environ, start_response): ... pass >>> loop = asyncio.get_event_loop() >>> srv = create_server(application, loop=loop, port=2345) >>> srv.close() Then use ``srv.run()`` or ``loop.run_forever()`` """ if 'loop' in adj: loop = adj.pop('loop') else: loop = asyncio.get_event_loop() if 'ident' not in adj: adj['ident'] = 'aiowsgi' server = waitress.create_server(application, _start=False, **adj) adj = server.adj server.executor = None if not asyncio.iscoroutine(application) and \ not asyncio.iscoroutinefunction(application): server.executor = ThreadPoolExecutor(max_workers=adj.threads) server.run = loop.run_forever server.loop = loop args = dict(app=[application], aioserver=None, adj=adj, loop=loop, server=server, server_name=server.server_name, effective_host=server.effective_host, effective_port=server.effective_port) proto = type(str('BoundedWSGIProtocol'), (WSGIProtocol,), args) server.proto = proto if adj.unix_socket: utilities.cleanup_unix_socket(adj.unix_socket) f = loop.create_unix_server else: f = loop.create_server def done(future): result = future.result() server.aioserver = result task = asyncio.ensure_future( f(proto, sock=server.socket, backlog=adj.backlog, ssl=ssl), loop=loop) task.add_done_callback(done) return server def serve(application, **kw): # pragma: no cover """Serve a wsgi application""" no_async = kw.pop('no_async', False) if not no_async: kw['_server'] = create_server return waitress.serve(application, **kw) def serve_paste(app, global_conf, **kw): serve(app, **kw) return 0 def run(argv=sys.argv): from waitress import runner runner.run(argv=argv, _serve=serve) aiowsgi_0.7.orig/aiowsgi/compat.py0000644000000000000000000000015312350526062015470 0ustar 00000000000000# -*- coding: utf-8 -*- try: import trollius as asyncio except ImportError: import asyncio # NOQA aiowsgi_0.7.orig/aiowsgi/task.py0000644000000000000000000001320213367123162015151 0ustar 00000000000000from .compat import asyncio from waitress.task import reraise from waitress.task import hop_by_hop from waitress.task import ErrorTask # NOQA from waitress.task import WSGITask as Task from waitress.task import ReadOnlyFileBasedBuffer as ROBuffer class WSGITask(Task): """A WSGI task produces a response from a WSGI application. """ environ = None def execute(self): env = self.get_environment() env['aiowsgi.loop'] = self.channel.server.loop def start_response(status, headers, exc_info=None): if self.complete and not exc_info: raise AssertionError("start_response called a second time " "without providing exc_info.") if exc_info: # pragma: no cover try: if self.complete: # higher levels will catch and handle raised exception: # 1. "service" method in task.py # 2. "service" method in channel.py # 3. "handler_thread" method in task.py reraise(exc_info[0], exc_info[1], exc_info[2]) else: # As per WSGI spec existing headers must be cleared self.response_headers = [] finally: exc_info = None self.complete = True if status.__class__ is not str: # pragma: no cover raise AssertionError('status %s is not a string' % status) self.status = status # Prepare the headers for output for k, v in headers: if k.__class__ is not str: raise AssertionError( 'Header name %r is not a string in %r' % (k, (k, v)) ) if v.__class__ is not str: raise AssertionError( 'Header value %r is not a string in %r' % (v, (k, v)) ) kl = k.lower() if kl == 'content-length': self.content_length = int(v) elif kl in hop_by_hop: # pragma: no cover raise AssertionError( '%s is a "hop-by-hop" header; it cannot be used by ' 'a WSGI application (see PEP 3333)' % k) self.response_headers.extend(headers) # Return a method used to write the response data. return self.write # Call the application to handle the request and write a response loop = self.channel.server.loop if self.channel.server.executor is not None: coro = loop.run_in_executor( self.channel.server.executor, self.channel.server.application, env, start_response) else: coro = self.channel.server.application(env, start_response) t = asyncio.ensure_future(coro, loop=loop) t.add_done_callback(self.aiofinish) def finish(self): pass def aiofinish(self, f): app_iter = f.result() self.aioexecute(app_iter) Task.finish(self) if self.close_on_finish: # pragma: no cover self.channel.transport.close() def aioexecute(self, app_iter): try: if app_iter.__class__ is ROBuffer: # pragma: no cover cl = self.content_length size = app_iter.prepare(cl) if size: if cl != size: if cl is not None: self.remove_content_length_header() self.content_length = size self.write(b'') # generate headers self.channel.write_soon(app_iter) return first_chunk_len = None for chunk in app_iter: if first_chunk_len is None: first_chunk_len = len(chunk) # Set a Content-Length header if one is not supplied. # start_response may not have been called until first # iteration as per PEP, so we must reinterrogate # self.content_length here if self.content_length is None: # pragma: no cover app_iter_len = None if hasattr(app_iter, '__len__'): app_iter_len = len(app_iter) if app_iter_len == 1: self.content_length = first_chunk_len # transmit headers only after first iteration of the iterable # that returns a non-empty bytestring (PEP 3333) if chunk: self.write(chunk) cl = self.content_length if cl is not None: if self.content_bytes_written != cl: # pragma: no cover # close the connection so the client isn't sitting around # waiting for more data when there are too few bytes # to service content-length self.close_on_finish = True if self.request.command != 'HEAD': self.logger.warning( 'application returned too few bytes (%s) ' 'for specified Content-Length (%s) via app_iter' '' % ( self.content_bytes_written, cl), ) finally: if hasattr(app_iter, 'close'): # pragma: no cover app_iter.close() self.channel.done.set_result(True) aiowsgi_0.7.orig/aiowsgi/thread.py0000644000000000000000000000522312502555503015460 0ustar 00000000000000# -*- coding: utf-8 -*- import time import socket import threading from . import asyncio from . import create_server from six.moves import http_client def get_free_port(): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', 0)) ip, port = s.getsockname() s.close() return ip, port def check_server(host, port, path_info='/', timeout=3, retries=30): """Perform a request until the server reply""" if retries < 0: return 0 time.sleep(.3) for i in range(retries): try: conn = http_client.HTTPConnection(host, int(port), timeout=timeout) conn.request('GET', path_info) res = conn.getresponse() return res.status except (socket.error, http_client.HTTPException): print('wait') time.sleep(.3) return 0 class WSGIServer(threading.Thread): """Stopable WSGI server running in a thread (not main thread). Usefull for functionnal testing. Usage: .. code-block:: >>> @asyncio.coroutine ... def application(environ, start_response): ... start_response('200 OK', []) ... return ['Hello world'] >>> loop = asyncio.get_event_loop() >>> server = WSGIServer(application) >>> server.start() >>> server.stop() ``server.url`` will contain the url to request """ def __init__(self, app, host='127.0.0.1', port=None): super(WSGIServer, self).__init__() self.server = None self.app = app _, self.port = port or get_free_port() self.host = host self.url = 'http://%s:%s' % (self.host, self.port) self.loop = asyncio.new_event_loop() def run(self): asyncio.set_event_loop(self.loop) self.server = create_server( self.app, loop=self.loop, host=self.host, port=self.port) self.server.run() def wait(self): info = (self.host, self.port) status = check_server(*info) if status not in (200, 399): self.loop.call_soon_threadsafe(self._stop) info += (status,) raise RuntimeError( 'Not able to connect to server at %s:%s (%s)' % info) def _stop(self): if self.server is not None: if getattr(self.server, 'aioserver', None) is not None: try: self.server.aioserver.close() except TypeError: pass self.server.close() self.loop.stop() def start(self): super(WSGIServer, self).start() self.wait() def stop(self): self.loop.call_soon_threadsafe(self._stop) aiowsgi_0.7.orig/docs/Makefile0000644000000000000000000001270712333034262014566 0ustar 00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = ../bin/sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/aiowsgi.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/aiowsgi.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/aiowsgi" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/aiowsgi" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." aiowsgi_0.7.orig/docs/conf.py0000644000000000000000000001732512333034262014426 0ustar 00000000000000# -*- coding: utf-8 -*- # # aiowsgi documentation build configuration file, created by # sphinx-quickstart on Thu May 8 23:21:43 2014. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'aiowsgi' copyright = u'2014, Gael Pasgrimaud' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '' # The full version, including alpha/beta/rc tags. release = '' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'aiowsgidoc' # -- Options for LaTeX output -------------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'aiowsgi.tex', u'aiowsgi Documentation', u'Gael Pasgrimaud', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'aiowsgi', u'aiowsgi Documentation', [u'Gael Pasgrimaud'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'aiowsgi', u'aiowsgi Documentation', u'Gael Pasgrimaud', 'aiowsgi', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' html_theme = 'nature' import pkg_resources version = pkg_resources.get_distribution("aiowsgi").version release = version aiowsgi_0.7.orig/docs/index.rst0000644000000000000000000000156012500616622014764 0ustar 00000000000000.. aiowsgi documentation master file, created by sphinx-quickstart on Thu May 8 23:21:43 2014. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. .. include:: ../README.rst Usage ===== Install the software: .. code-block:: sh $ pip install aiowsgi Launch the server: .. code-block:: sh $ aiowsgi yourmodule:application $ aiowsgi -h You can also use a paste factory .. code-block:: ini [server:main] use = egg:aiowsgi Notice that all options will not work. aiowsgi just use ``waitress`` with a custom server factory but not all adjustments are implemented. API === .. autofunction:: aiowsgi.serve .. autofunction:: aiowsgi.create_server .. autoclass:: aiowsgi.thread.WSGIServer Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` aiowsgi_0.7.orig/tests/__init__.py0000644000000000000000000000001312333034262015434 0ustar 00000000000000# package aiowsgi_0.7.orig/tests/apps.py0000644000000000000000000000043412350526062014652 0ustar 00000000000000# -*- coding: utf-8 -*- import webob from aiowsgi.compat import asyncio resp = webob.Response('It works!') @asyncio.coroutine def aioapp(environ, start_response): return resp(environ, start_response) def app(environ, start_response): return resp(environ, start_response) aiowsgi_0.7.orig/tests/test_aiowsgi.py0000644000000000000000000000520612502555503016413 0ustar 00000000000000# -*- coding: utf-8 -*- from webtest.debugapp import debug_app from webtest import http from unittest import TestCase from aiowsgi.compat import asyncio import aiowsgi import socket class Transport(object): _sock = socket.socket() def __init__(self): self.data = b'' self.closed = False def get_extra_info(self, *args): return ('1.1.1.1', 5678) def write(self, data): self.data += data def close(self): self.closed = True class TestHttp(TestCase): loop = asyncio.new_event_loop() app = debug_app def callFTU(self, **kw): kw['host'], kw['port'] = http.get_free_port() s = aiowsgi.create_server(self.app, threads=1, loop=self.loop, **kw).proto() s.connection_made(Transport()) return s def test_get(self): p = self.callFTU() t = p.transport channel = p.data_received(b'GET / HTTP/1.1\r\n\r\n') self.loop.run_until_complete(channel.done) self.assertFalse(p.request) self.assertIn(b'REQUEST_METHOD: GET', t.data) def test_post(self): p = self.callFTU() t = p.transport channel = p.data_received( b'POST / HTTP/1.1\r\nContent-Length: 1\r\n\r\nX') self.loop.run_until_complete(channel.done) self.assertFalse(p.request) self.assertIn(b'REQUEST_METHOD: POST', t.data) self.assertIn(b'CONTENT_LENGTH: 1', t.data) def test_post_error(self): p = self.callFTU(max_request_body_size=1) p.data_received( b'POST / HTTP/1.1\r\nContent-Length: 1025\r\n\r\nB') self.assertFalse(p.request) class TestAsyncHttp(TestHttp): @asyncio.coroutine def app(self, *args): resp = list(debug_app.__call__(*args)) return resp class Loop(asyncio.get_event_loop().__class__): def get_debug(self): return True @asyncio.coroutine def create_server(self, *args, **kwargs): pass @asyncio.coroutine def create_unix_server(self, *args, **kwargs): pass def call_soon(self, callback, *args): callback(*args) def run_forever(self): pass class TestServe(TestCase): def setUp(self): loop = asyncio.get_event_loop() self.addCleanup(asyncio.set_event_loop, loop) asyncio.set_event_loop(Loop()) def test_serve(self): aiowsgi.serve(debug_app) def test_serve_unix(self): aiowsgi.serve(debug_app, unix_socket='/tmp/sock') def test_serve_paste(self): aiowsgi.serve_paste(debug_app, {}) def test_run(self): aiowsgi.run(['', 'tests.apps:aioapp']) aiowsgi_0.7.orig/tests/test_thread.py0000644000000000000000000000071312500615255016215 0ustar 00000000000000# -*- coding: utf-8 -*- from aiowsgi.thread import WSGIServer from webtest.debugapp import debug_app from webtest import TestApp from unittest import TestCase class TestHttp(TestCase): def setUp(self): server = WSGIServer(debug_app) server.start() self.addCleanup(server.stop) self.app = TestApp(server.url) def test_page(self): resp = self.app.get('/') resp.mustcontain('SERVER_SOFTWARE: aiowsgi')