Skip to content

Commit

Permalink
Add tox configuration and static code analysis (flake8, pylint)
Browse files Browse the repository at this point in the history
Convert README to reStructuredText (was: MarkDown) for PyPI

Add full text of license (identical to Sentry project)

Use standard naming for contributors file

Move package information to __init__ file
  • Loading branch information
bittner committed Jun 7, 2016
1 parent 3d3a8db commit 5c81ef6
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ build/config/buildinfo.properties
env

# Packages
*.egg
*.egg[s]
*.egg-info
dist
build
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Mauro De Giorgi (mdgart)
Julian Perelli (jperelli)
Peter Bittner (bittner)
4 changes: 3 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ v0.0.5, 12/05/2012 -- Django settings eliminated
v0.0.6, 12/05/2012 -- Nginx default error log path fixed
v0.0.7, 12/10/2012 -- Documentation bug fix
v0.0.8, 01/16/2013 -- README.md addded to manifest
v0.0.9, 02/18/2013 -- Patch for invalid Nginx errors
v0.0.9, 02/18/2013 -- Patch for invalid Nginx errors
v1.0.0, ??/??/???? -- (non-versioned release)
v1.1.0, 06/07/2016 -- Add static code analysis (flake8, pylint)
12 changes: 12 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Copyright (c) 2012-2016 Mauro De Giorgi (mdgart) and individual contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the Sentry nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include *.txt
include *.md
include *.rst
recursive-include docs *.txt
recursive-include sentrylogs/conf *.py
prune sentrylogs/env
36 changes: 15 additions & 21 deletions README.md → README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Sentry Logs
===========

Sentry Logs allows you to send Logs to Sentry, only Nginx error log is currently supported,
but I'm planning to extend the library to support more logs file.

Sentry Logs allows you to send Logs to Sentry, only Nginx error log is
currently supported, but extending the library to support more log files
is planned.

How it works
============
Expand All @@ -17,10 +17,9 @@ or::

easy_install sentrylogs

This will install the module and you will have a new command line available::

sentrylogs -h
This will install the module and will provide a new console command::

$ sentrylogs -h

usage: sentrylogs [-h] [--follow FOLLOW] [--sentrydsn SENTRYDSN] [--daemonize]
[--nginxerrorpath NGINXERRORPATH]
Expand All @@ -37,24 +36,19 @@ This will install the module and you will have a new command line available::
--nginxerrorpath NGINXERRORPATH, -n NGINXERRORPATH
Nginx error log path

You must provide a Sentry DSN to make it work; you have 2 possibilities:

you must provide a Sentry DSN to make it works; at this moment you have 2 possibilities:

set up an environment variable:

$ export SENTRY_DSN="protocol://public:secret@example.com/#"
$ sentrylogs

or use the --sentrydsn argument:

$ sentrylogs --sentrydsn "protocol://public:secret@example.com/#"

By defauld it will seach for nginx log at /var/log/nginx/error.log, but you can change it using --nginxerrorpath

If you use --daemonize the command will daemonize itself and will run in background.

Provide an environment variable::

$ export SENTRY_DSN="protocol://public:[email protected]/#"
$ sentrylogs

or use the ``--sentrydsn`` command line argument::

$ sentrylogs --sentrydsn "protocol://public:[email protected]/#"

By default *sentrylogs* will assume the nginx log at ``/var/log/nginx/error.log``,
but you can change this using the ``--nginxerrorpath`` argument.

If you use ``--daemonize`` the command will daemonize itself and run in
background.
2 changes: 0 additions & 2 deletions contributors.txt

This file was deleted.

2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
raven>=2.0.10
tailer>=0.3
9 changes: 8 additions & 1 deletion sentrylogs/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@

"""
Send logs to Django Sentry.
"""
__author__ = 'Mauro De Giorgi'
__author_email__ = '[email protected]'
__license__ = 'BSD'
__url__ = 'https://github.com/mdgart/sentrylogs'
__version__ = '1.1.0.dev'
111 changes: 98 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,103 @@
from glob import glob
from setuptools import setup
from setuptools.command.test import test as TestCommand # noqa N812
from shlex import split
from shutil import rmtree
from os import remove
from os.path import abspath, dirname, join

import sentrylogs as package


class Tox(TestCommand):
user_options = [('tox-args=', 'a', "Arguments to pass to tox")]

def initialize_options(self):
TestCommand.initialize_options(self)
self.tox_args = None

def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True

def run_tests(self):
from tox import cmdline
args = self.tox_args
if args:
args = split(self.tox_args)
errno = cmdline(args=args)
exit(errno)


class Clean(TestCommand):
def run(self):
delete_in_root = [
'build',
'dist',
'.eggs',
'*.egg-info',
'.tox',
]
delete_everywhere = [
'__pycache__',
'*.pyc',
]
for candidate in delete_in_root:
rmtree_glob(candidate)
for visible_dir in glob('[A-Za-z0-9]*'):
for candidate in delete_everywhere:
rmtree_glob(join(visible_dir, candidate))
rmtree_glob(join(visible_dir, '*', candidate))
rmtree_glob(join(visible_dir, '*', '*', candidate))


def rmtree_glob(file_glob):
for fobj in glob(file_glob):
try:
rmtree(fobj)
print('%s/ removed ...' % fobj)
except OSError:
try:
remove(fobj)
print('%s removed ...' % fobj)
except OSError as err:
print(err)


def read_file(filename):
with open(join(abspath(dirname(__file__)), filename)) as f:
return f.read()


setup(
name='SentryLogs',
version='0.0.9',
author='Mauro De Giorgi',
author_email='[email protected]',
scripts=['bin/sentrylogs',],
version=package.__version__,
author=package.__author__,
author_email=package.__author_email__,
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
description=package.__doc__.strip(),
long_description=read_file('README.rst'),
license=package.__license__,
url=package.__url__,
install_requires=read_file('requirements.txt'),
scripts=['bin/sentrylogs'],
packages=['sentrylogs', 'sentrylogs.conf', 'sentrylogs.parsers'],
url='http://pypi.python.org/pypi/SentryLogs/',
license='LICENSE.txt',
description='Send logs to Django Sentry.',
long_description=open('README.md').read(),
install_requires=[
"raven >= 2.0.10",
"tailer >= 0.3",
],
)
test_suite='tests',
tests_require=['tox'],
cmdclass={
'clean': Clean,
'test': Tox,
},
)
32 changes: 32 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[flake8]
max-line-length = 90
exclude = build,dist,reports,*.egg-info

[pylint]
;disable = invalid-name,missing-docstring
;ignore = migrations
;ignore-docstrings = yes
output-format = colorized
reports = no

[tox]
envlist =
flake8
pylint
; py{26,27}
; py{32,33,34,35}

[testenv]
basepython = python3.4
;deps = pytest
commands =
python setup.py -q install
py.test

[testenv:flake8]
deps = flake8
commands = flake8

[testenv:pylint]
deps = pylint
commands = pylint --rcfile=tox.ini sentrylogs

0 comments on commit 5c81ef6

Please sign in to comment.