Skip to content
This repository has been archived by the owner on Nov 23, 2020. It is now read-only.

Commit

Permalink
removed agile scripts, everything in setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lsbardel committed May 12, 2016
1 parent cccc844 commit f110e30
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 97 deletions.
4 changes: 0 additions & 4 deletions agileplay.py

This file was deleted.

5 changes: 1 addition & 4 deletions pulsar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -
'''Event driven concurrent framework for Python'''
"""Event driven concurrent framework for Python"""
import os

from .utils.version import get_version
Expand Down Expand Up @@ -34,7 +34,4 @@
from .utils.config import * # noqa
from .async import * # noqa
from .apps import * # noqa

del get_version
# Import data stores
from .apps.data import data_stores # noqa
21 changes: 11 additions & 10 deletions pulsar/apps/http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def __init__(self, client, url, method, inp_params=None, headers=None,
if auth and not isinstance(auth, Auth):
auth = HTTPBasicAuth(*auth)
self.auth = auth
self.headers = client.get_headers(self, headers)
self.headers = client._get_headers(headers)
self.url = self._full_url(url, params)
self.body = self._encode_body(data, files, json)
self._set_proxy(proxies, ignored)
Expand Down Expand Up @@ -496,7 +496,7 @@ def _set_proxy(self, proxies, ignored):
self.unredirected_headers['host'] = host_no_default_port(url.scheme,
url.netloc)
if url.scheme in tls_schemes:
self._ssl = self.client.ssl_context(verify=self.verify, **ignored)
self._ssl = self.client._ssl_context(verify=self.verify, **ignored)

request_proxies = self.client.proxies.copy()
if proxies:
Expand Down Expand Up @@ -783,15 +783,15 @@ class HttpClient(AbstractClient):
It can be overwritten on :meth:`request`.
"""
DEFAULT_HTTP_HEADERS = Headers([
DEFAULT_HTTP_HEADERS = Headers((
('Connection', 'Keep-Alive'),
('Accept', '*/*'),
('Accept-Encoding', 'deflate'),
('Accept-Encoding', 'gzip')],
('Accept-Encoding', 'gzip')),
kind='client')
DEFAULT_TUNNEL_HEADERS = Headers([
DEFAULT_TUNNEL_HEADERS = Headers((
('Connection', 'Keep-Alive'),
('Proxy-Connection', 'Keep-Alive')],
('Proxy-Connection', 'Keep-Alive')),
kind='client')
request_parameters = ('max_redirects', 'decompress',
'websocket_handler', 'version',
Expand Down Expand Up @@ -843,6 +843,7 @@ def __init__(self, proxies=None, headers=None, verify=True,
self.bind_event('on_headers', handle_cookies)
self.bind_event('post_request', Redirect())

# API
def connect(self, address):
if isinstance(address, tuple):
address = ':'.join(('%s' % v for v in address))
Expand Down Expand Up @@ -974,17 +975,17 @@ async def _request(self, method, url, **params):
response = await self._request(method, url, **params)
return response

def get_headers(self, request, headers=None):
def _get_headers(self, headers=None):
# Returns a :class:`Header` obtained from combining
# :attr:`headers` with *headers*. Can handle websocket requests.
d = self.headers.copy()
if headers:
d.override(headers)
return d

def ssl_context(self, verify=True, cert_reqs=None,
check_hostname=False, certfile=None, keyfile=None,
cafile=None, capath=None, cadata=None, **kw):
def _ssl_context(self, verify=True, cert_reqs=None,
check_hostname=False, certfile=None, keyfile=None,
cafile=None, capath=None, cadata=None, **kw):
assert ssl, 'SSL not supported'
cafile = cafile or DEFAULT_CA_BUNDLE_PATH

Expand Down
61 changes: 0 additions & 61 deletions pulsar_config.py

This file was deleted.

4 changes: 2 additions & 2 deletions pulsar_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Test(orig.test):
test_suite = True
start_coverate = False
start_coverage = False
list_options = set(['log-level=', 'test-plugins=',
'test-modules=', 'pulsar-args='])
user_options = [
Expand Down Expand Up @@ -38,7 +38,7 @@ def finalize_options(self):
self.test_args = self.pulsar_args or []

def run_tests(self):
if self.coverage and self.start_coverate:
if self.coverage and self.start_coverage:
import coverage
from coverage.monkey import patch_multiprocessing
p = current_process()
Expand Down
88 changes: 76 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,69 @@
#!/usr/bin/env python
import sys
import os
import json
import subprocess

from setuptools import setup, find_packages
from extensions import ext

import pulsar_config as config
import pulsar_test


class PulsarTest(pulsar_test.Test):
start_coverage = True


def extend(params, package=None):
if package:
path = os.path.dirname(__file__)
data = sh('%s %s package_info %s %s'
% (sys.executable, __file__, package, path))
params.update(json.loads(data))

return params


def read(name):
filename = os.path.join(os.path.dirname(__file__), name)
with open(filename) as fp:
return fp.read()


def requirements(name):
install_requires = []
dependency_links = []

for line in read(name).split('\n'):
if line.startswith('-e '):
link = line[3:].strip()
if link == '.':
continue
dependency_links.append(link)
line = link.split('=')[1]
line = line.strip()
if line:
install_requires.append(line)

return install_requires, dependency_links


def sh(command):
return subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
universal_newlines=True).communicate()[0]


meta = dict(
name='pulsar',
author="Luca Sbardella",
author_email="[email protected]",
maintainer_email="[email protected]",
url="https://github.com/quantmind/pulsar",
license="BSD",
long_description=config.read('README.rst'),
long_description=read('README.rst'),
include_package_data=True,
setup_requires=['wheel'],
packages=find_packages(include=['pulsar', 'pulsar.*', 'pulsar_test']),
Expand Down Expand Up @@ -43,22 +93,36 @@
)


class PulsarTest(pulsar_test.Test):
start_coverate = True


def run_setup(with_cext):
params = ext.params() if with_cext else {}
params.update(meta)
cmdclass = params.get('cmdclass', {})
cmdclass['test'] = PulsarTest
params['cmdclass'] = cmdclass
setup(**config.setup(params, 'pulsar'))
setup(**extend(params, 'pulsar'))


def package_info():
package = sys.argv[2]
if len(sys.argv) > 3:
sys.path.append(sys.argv[3])
os.environ['package_info'] = package
pkg = __import__(package)
print(json.dumps(dict(version=pkg.__version__,
description=pkg.__doc__)))


if __name__ == '__main__':
try:
run_setup(True)
except ext.BuildFailed as exc:
print('WARNING: C extensions could not be compiled: %s' % exc.msg)
run_setup(False)
command = sys.argv[1] if len(sys.argv) > 1 else None
if command == 'package_info':
package_info()
elif command == 'agile':
from agile import AgileManager
AgileManager(description='Release manager for pulsar',
argv=sys.argv[2:]).start()
else:
try:
run_setup(True)
except ext.BuildFailed as exc:
print('WARNING: C extensions could not be compiled: %s' % exc.msg)
run_setup(False)
8 changes: 4 additions & 4 deletions tests/http/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def test_http11_close(self):
http = self.client()
self.assertEqual(http.version, 'HTTP/1.1')
response = yield from http.get(
self.httpbin(), headers=[('connection', 'close')])
self.httpbin(), headers={'connection': 'close'})
self.assertEqual(response.headers['connection'], 'close')
self._check_pool(http, response, available=0)

Expand Down Expand Up @@ -653,7 +653,7 @@ def test_media_file(self):
# Test if modified since
response = yield from http.get(
self.httpbin('media/httpbin.js'),
headers=[('If-modified-since', modified)])
headers={'If-modified-since': modified})
self.assertEqual(response.status_code, 304)
self.assertFalse('Content-length' in response.headers)

Expand Down Expand Up @@ -758,7 +758,7 @@ def test_pool_400(self):
def test_415(self):
http = self._client
response = yield from http.get(
self.httpbin(''), headers=[('accept', 'application/json')])
self.httpbin(''), headers={'accept': 'application/json'})
self.assertEqual(response.status_code, 415)

@unittest.skipUnless(linux, 'Test in linux platform only')
Expand Down Expand Up @@ -826,7 +826,7 @@ def gen():
fut._loop.call_later(0.5, fut.set_result, result)
response = yield from http.post(
self.httpbin('post_chunks'),
headers=[('content-type', 'text/plain')],
headers={'content-type': 'text/plain'},
data=gen())
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.content), 300)
Expand Down

0 comments on commit f110e30

Please sign in to comment.