-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from EasyPost/cleanup
chore: cleanup docs and CI
- Loading branch information
Showing
11 changed files
with
416 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ test-*.xml | |
venv/ | ||
env/ | ||
.coverage | ||
__pycache__ | ||
*.lcov |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
0.4.0 | ||
----- | ||
# CHANGELOG | ||
|
||
## v1.0.0 FUTURE | ||
|
||
- Drops support for Python earlier than 3.7 | ||
- Adds support for Python 3.10-3.12 | ||
- Overhauls dev tooling | ||
|
||
## v0.4.0 | ||
|
||
- pass through SIGTERM, SIGQUIT, and SIGINT to the child process | ||
- do not send empty tags to Sentry | ||
- (internal) switch tests from circleci to travisci | ||
|
||
0.3.2 | ||
----- | ||
## v0.3.2 | ||
|
||
- Move `level`, `server_name` and `sdk` from `tags` to top-level | ||
- Add Python 3.6 to tox tests | ||
|
||
0.3.1 | ||
----- | ||
## v0.3.1 | ||
|
||
- Fix bug with loading large command outputs | ||
- Add more tests | ||
|
||
0.3.0 | ||
----- | ||
## v0.3.0 | ||
|
||
- Add support for using `requests` if it's importable | ||
- Add support for outbound proxies via `$SHELL_SENTRY_PROXY` or `/etc/shentry_proxy` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
PYTHON_BINARY := python3 | ||
VIRTUAL_ENV := venv | ||
VIRTUAL_BIN := $(VIRTUAL_ENV)/bin | ||
PROJECT_NAME := shentry | ||
TEST_DIR := tests | ||
|
||
## help - Display help about make targets for this Makefile | ||
help: | ||
@cat Makefile | grep '^## ' --color=never | cut -c4- | sed -e "`printf 's/ - /\t- /;'`" | column -s "`printf '\t'`" -t | ||
|
||
## clean - Clean the project | ||
clean: | ||
rm -rf $(VIRTUAL_ENV) dist/ *.egg-info/ .*cache htmlcov *.lcov .coverage | ||
find . -name '*.pyc' -delete | ||
|
||
## coverage - Test the project and generate an HTML coverage report | ||
coverage: | ||
$(VIRTUAL_BIN)/pytest --cov=$(PROJECT_NAME) --cov-branch --cov-report=html --cov-report=lcov --cov-report=term-missing --cov-fail-under=50 | ||
|
||
## flake8 - Lint the project with flake8 | ||
flake8: | ||
$(VIRTUAL_BIN)/flake8 $(PROJECT_NAME).py $(TEST_DIR)/ | ||
|
||
## install - Install the project locally | ||
install: | ||
$(PYTHON_BINARY) -m venv $(VIRTUAL_ENV) | ||
$(VIRTUAL_BIN)/pip install -r requirements-tests.txt -e . | ||
|
||
## lint - Run linters on the project | ||
lint: flake8 | ||
|
||
## publish - Publish the project to PyPI | ||
publish: | ||
$(VIRTUAL_BIN)/twine upload dist/* | ||
|
||
## test - Test the project | ||
test: | ||
$(VIRTUAL_BIN)/pytest | ||
|
||
.PHONY: help clean coverage flake8 install lint publish test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,16 @@ | ||
# Shentry | ||
|
||
[![Build Status](https://travis-ci.com/EasyPost/shentry.svg?branch=master)](https://travis-ci.com/EasyPost/shentry) | ||
[![Coverage Status](https://coveralls.io/repos/github/EasyPost/shentry/badge.svg)](https://coveralls.io/github/EasyPost/shentry) | ||
[![Version](https://img.shields.io/github/v/tag/EasyPost/shentry)](https://github.com/EasyPost/shentry/releases) | ||
|
||
**Shentry** is a single-file Python script which will run the wrapped | ||
command and, if it fails, post an event to Sentry. By default, if the | ||
wrapped script succeeds (exists with code 0), stdout/stderr are squashed, | ||
similarly to [shuck](https://github.com/thwarted/shuck) or | ||
[chronic](https://joeyh.name/code/moreutils/). It also always exits with | ||
status 0 if events are able to be sent to Sentry. | ||
|
||
It reads its configuration from the environment variable `$SHELL_SENTRY_DSN` | ||
and, if such a variable is found, removes it from the environment before | ||
calling the wrapped program. If that environment variable is not present, shentry will look | ||
for `$SENTRY_DSN` (and similarly remove it from the environment). | ||
If you need to use SENTRY_DSN inside your project code, make sure to set both. | ||
You may also in that case want to put a top-level try/except around your whole | ||
program to prevent uncaught exceptions from trigging both your in-process sentry sdk | ||
and also your extra-process shentry, since you very likely only want one or the other. | ||
If neither of the environment variables are present or both | ||
are empty, shentry will try to read a DSN from `/etc/shentry_dsn`. If no DSN | ||
can be found, the wrapped will have normal behavior (stdout/stderr will go | ||
to their normal file descriptors, exit code will be passed through, etc). | ||
|
||
This software should be compatible with Python 2.6, 2.7, and 3.5+; | ||
that is to say, you should be able to run it just about anywhere. | ||
|
||
[![Build Status](https://travis-ci.com/EasyPost/shentry.svg?branch=master)](https://travis-ci.com/EasyPost/shentry) | ||
|
||
|
||
## Installation | ||
|
||
Put the file [`shentry.py`](shentry.py) anywhere in your `$PATH` under the | ||
|
@@ -34,27 +21,46 @@ If the `requests` library is available, it will be used; otherwise, the standard | |
either `$SHELL_SENTRY_PROXY` or the contents of `/etc/shentry_proxy` can be | ||
used to configure an outbound proxy. | ||
|
||
The `setup.py` in this directory only exists for `tox` to work (and run unit | ||
tests). Don't bother using it; just copy `shentry.py` wherever you want it. | ||
The `setup.py` in this directory only exists for this project's dev tooling. To get | ||
Shentry working on your machine, simply copy `shentry.py` wherever you need it. | ||
|
||
## Usage | ||
|
||
You might want a crontab that looks something like the following: | ||
|
||
SHELL_SENTRY_DSN=https://pub:[email protected]/id | ||
```sh | ||
SHELL_SENTRY_DSN=https://pub:[email protected]/id | ||
|
||
15 * * * * /usr/local/bin/shentry /usr/local/bin/run-periodic-scripts | ||
15 * * * * /usr/local/bin/shentry /usr/local/bin/run-periodic-scripts | ||
``` | ||
|
||
You can also make shentry your `$SHELL` and wrap all commands in it: | ||
|
||
SHELL_SENTRY_DSN=https://pub:[email protected]/id | ||
SHELL=/usr/local/bin/shentry | ||
```sh | ||
SHELL_SENTRY_DSN=https://pub:[email protected]/id | ||
SHELL=/usr/local/bin/shentry | ||
|
||
15 * * * * /usr/local/bin/run-periodic-scripts | ||
7 1 * * * /usr/local/bin/run-daily-scripts | ||
15 * * * * /usr/local/bin/run-periodic-scripts | ||
7 1 * * * /usr/local/bin/run-daily-scripts | ||
``` | ||
|
||
In this case, it will run the wrapped commands through `/bin/sh` (otherwise, it will honor `$SHELL`). | ||
|
||
### Environment Variables | ||
|
||
Shentry reads its configuration from the environment variable `$SHELL_SENTRY_DSN` | ||
and, if such a variable is found, removes it from the environment before | ||
calling the wrapped program. If that environment variable is not present, shentry will look | ||
for `$SENTRY_DSN` (and similarly remove it from the environment). | ||
If you need to use `SENTRY_DSN` inside your project code, make sure to set both. | ||
You may also in that case want to put a top-level try/except around your whole | ||
program to prevent uncaught exceptions from trigging both your in-process sentry sdk | ||
and also your extra-process shentry, since you very likely only want one or the other. | ||
If neither of the environment variables are present or both | ||
are empty, shentry will try to read a DSN from `/etc/shentry_dsn`. If no DSN | ||
can be found, the wrapped will have normal behavior (stdout/stderr will go | ||
to their normal file descriptors, exit code will be passed through, etc). | ||
|
||
## License | ||
|
||
This software is licensed under the ISC License, the full text of which can be found at [LICENSE.txt](LICENSE.txt). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
# pytest can't go above 3.2 because we need python 2.6 compat | ||
pytest==3.2.* | ||
# pytest 2.6 also breaks python 2.6 compatibility | ||
pytest-cov==2.5.* | ||
mock==2.0.0 | ||
pytest-mock==1.* | ||
flake8==3.* | ||
flake8==5.* # TODO: flake8 v6 requires Python 3.8.1+ | ||
pytest-cov==4.* | ||
pytest-mock==3.* | ||
pytest==7.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,31 +2,30 @@ | |
|
||
from setuptools import setup | ||
|
||
|
||
setup( | ||
name="shentry", | ||
version="0.4.0", | ||
version="1.0.0", | ||
author="EasyPost", | ||
author_email="[email protected]", | ||
url="https://github.com/easypost/shentry", | ||
license="ISC", | ||
packages=[], | ||
scripts=['shentry.py'], | ||
scripts=["shentry.py"], | ||
keywords=["logging"], | ||
description="Wrap a program in sentry!", | ||
python_requires='>=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4', | ||
python_requires=">=3.7, <4", | ||
classifiers=[ | ||
"Development Status :: 3 - Alpha", | ||
"Environment :: Console", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 2.6", | ||
"Programming Language :: Python :: 2.7", | ||
"Programming Language :: Python :: 3.5", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Operating System :: POSIX", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: ISC License (ISCL)", | ||
] | ||
], | ||
) |
Oops, something went wrong.