Skip to content

Commit 882151b

Browse files
committed
Initial commit
0 parents  commit 882151b

13 files changed

+338
-0
lines changed

.coafile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[Default]
2+
files = **.(py|md|rst|yml), tox.ini, .coafile
3+
ignore = (.tox|env|.env|venv)/**
4+
5+
indent_size = 4
6+
use_spaces = True
7+
max_line_length = 120
8+
max_lines_per_file = 1000
9+
file_naming_convention = snake
10+
11+
[filenames]
12+
bears = FilenameBear
13+
files = aiohttp_sentry/**.py
14+
15+
[lengths]
16+
bears = LineCountBear, LineLengthBear
17+
18+
[spacing]
19+
ignore = (.tox|env|.env|venv)/**, **.yml, tox.ini, .coafile
20+
bears = SpaceConsistencyBear
21+
22+
[config-spacing]
23+
files = **.yml, tox.ini, .coafile
24+
bears = SpaceConsistencyBear
25+
indent_size = 2
26+
27+
[python-semantic]
28+
files = **.py
29+
bears = RadonBear, PyUnusedCodeBear
30+
language = python
31+
32+
[yaml]
33+
files = **.(yml|yaml)
34+
bears = YAMLLintBear
35+
36+
[restructuredtext]
37+
files = **.rst
38+
bears = reSTLintBear
39+
40+
[commit]
41+
bears = GitCommitBear
42+
shortlog_length = 72
43+
44+
[keywords]
45+
bears = KeywordBear
46+
keywords = TODO, FIXME, pdb.set_trace() # Ignore KeywordBear
47+
language = python

.gitignore

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#### joe made this: http://goel.io/joe
2+
3+
#####=== Python ===#####
4+
5+
# Byte-compiled / optimized / DLL files
6+
__pycache__/
7+
*.py[cod]
8+
9+
# C extensions
10+
*.so
11+
12+
# Distribution / packaging
13+
.Python
14+
env/
15+
build/
16+
develop-eggs/
17+
dist/
18+
downloads/
19+
eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.coverage
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
47+
# Translations
48+
*.mo
49+
*.pot
50+
51+
# Django stuff:
52+
*.log
53+
54+
# Sphinx documentation
55+
docs/_build/
56+
57+
# PyBuilder
58+
target/
59+
60+
#####=== Vim ===#####
61+
[._]*.s[a-w][a-z]
62+
[._]s[a-w][a-z]
63+
*.un~
64+
Session.vim
65+
.netrwhist
66+
*~
67+
68+
#####=== VirtualEnv ===#####
69+
# Virtualenv
70+
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
71+
.Python
72+
[Bb]in
73+
[Ii]nclude
74+
[Ll]ib
75+
[Ss]cripts
76+
pyvenv.cfg
77+
pip-selfcheck.json
78+
79+
#####=== OSX ===#####
80+
.DS_Store
81+
.AppleDouble
82+
.LSOverride
83+
84+
# Icon must end with two \r
85+
Icon
86+
87+
# Thumbnails
88+
._*
89+
90+
# Files that might appear on external disk
91+
.Spotlight-V100
92+
.Trashes
93+
94+
# Directories potentially created on remote AFP share
95+
.AppleDB
96+
.AppleDesktop
97+
Network Trash Folder
98+
Temporary Items
99+
.apdisk
100+

.pylintrc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[MASTER]
2+
# jobs=0 means 'use all CPUs'
3+
jobs=0
4+
5+
[MESSAGES CONTROL]
6+
disable =
7+
missing-docstring,
8+
line-too-long,
9+
invalid-name,
10+
no-value-for-parameter,
11+
no-member,
12+
unused-argument,
13+
broad-except,
14+
relative-import,
15+
wrong-import-position,
16+
bare-except,
17+
locally-disabled,
18+
protected-access,
19+
abstract-method,
20+
no-self-use,
21+
fixme,
22+
too-few-public-methods,
23+
24+
[REPORTS]
25+
output-format=colorized
26+
27+
[FORMAT]
28+
logging-modules=
29+
logging,
30+
structlog,
31+
32+
[TYPECHECK]
33+
# pygments: sys.modules hacks causing false positives - https://github.com/PyCQA/pylint/issues/491
34+
ignored-modules=
35+
pygments.lexers,
36+
pygments.formatters,

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# CHANGELOG
2+
3+
## 0.1.0 (2016-12-16)
4+
5+
Initial release.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Bence Nagy (underyx)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include README.rst
2+
include requirements.txt
3+
include test-requirements.txt

README.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
aiohttp-sentry
2+
==============
3+
4+
An aiohttp_ middleware for reporting errors to Sentry_. Python 3.5+ is required.
5+
6+
Usage
7+
-----
8+
9+
.. code-block:: python
10+
11+
from aiohttp import web
12+
from aiohttp_sentry import SentryMiddleware
13+
app = web.Application(
14+
middlewares=(
15+
SentryMiddleware,
16+
# ...
17+
),
18+
)
19+
20+
.. _aiohttp: http://aiohttp.readthedocs.io/en/stable/
21+
.. _Sentry: http://sentry.io/

aiohttp_sentry/__init__.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from functools import partial
2+
3+
import raven
4+
import raven_aiohttp
5+
6+
7+
class SentryMiddleware:
8+
9+
def __init__(self, sentry_kwargs=None):
10+
if sentry_kwargs is None:
11+
sentry_kwargs = {}
12+
13+
sentry_kwargs = {
14+
'transport': raven_aiohttp.AioHttpTransport,
15+
'enable_breadcrumbs': False,
16+
**sentry_kwargs,
17+
}
18+
self.client = raven.Client(**sentry_kwargs)
19+
20+
async def __call__(self, app, handler):
21+
return partial(self.middleware, handler)
22+
23+
async def middleware(self, handler, request):
24+
try:
25+
return await handler(request)
26+
except:
27+
self.client.captureException(data={
28+
'request': {
29+
'query_string': request.query_string,
30+
'cookies': request.headers.get('Cookie', ''),
31+
'headers': dict(request.headers),
32+
'url': request.path,
33+
'method': request.method,
34+
'env': {
35+
'REMOTE_ADDR': request.transport.get_extra_info('peername')[0],
36+
}
37+
}
38+
})
39+
raise

circle.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
dependencies:
2+
override:
3+
- pip install tox==2.4.* tox-pyenv==1.* tox-battery==0.2.*
4+
- pyenv local 3.5.2
5+
- tox --notest
6+
cache_directories:
7+
- .tox
8+
test:
9+
override:
10+
- tox -e coala -- --non-interactive
11+
- tox -e pylint

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
raven-aiohttp~=0.3.0
2+
raven~=5.27

setup.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import io
2+
from setuptools import setup
3+
4+
with io.open('requirements.txt') as f:
5+
install_requires = f.read().splitlines()
6+
7+
with io.open('test-requirements.txt') as f:
8+
tests_require = f.read().splitlines()
9+
10+
with io.open('README.rst') as f:
11+
long_description = f.read()
12+
13+
setup(
14+
name='aiohttp-sentry',
15+
version='0.1.0',
16+
url='https://github.com/underyx/aiohttp-sentry',
17+
author='Bence Nagy',
18+
author_email='[email protected]',
19+
maintainer='Bence Nagy',
20+
maintainer_email='[email protected]',
21+
download_url='https://github.com/underyx/aiohttp-sentry/releases',
22+
description='An aiohttp middleware for reporting errors to Sentry',
23+
long_description=long_description,
24+
packages=['aiohttp_sentry'],
25+
install_requires=install_requires,
26+
tests_require=tests_require,
27+
classifiers=[
28+
'Development Status :: 3 - Alpha',
29+
'License :: OSI Approved :: MIT License',
30+
'Operating System :: OS Independent',
31+
'Programming Language :: Python :: 3 :: Only',
32+
'Programming Language :: Python :: 3.5',
33+
],
34+
)

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pylint==1.*

tox.ini

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[tox]
2+
envlist =
3+
coala,
4+
pylint
5+
6+
[testenv:coala]
7+
basepython = python3.5
8+
deps = coala-bears==0.9.*
9+
skip_install = True
10+
commands = coala {posargs:}
11+
12+
[testenv:pylint]
13+
basepython = python3.5
14+
deps =
15+
-rrequirements.txt
16+
-rtest-requirements.txt
17+
commands =
18+
pylint --reports no {posargs:} aiohttp_sentry

0 commit comments

Comments
 (0)