From e535a33bd94690e7910fa04c999e841a26ad92d1 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Mon, 20 Nov 2023 13:53:50 -0700 Subject: [PATCH] chore: cleanup docs and CI --- .github/workflows/ci.yml | 16 +++++------ .travis.yml | 15 ----------- README.md | 58 +++++++++++++++++++++------------------- setup.py | 11 +++++--- 4 files changed, 46 insertions(+), 54 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e3864a..88aae4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,18 +2,18 @@ name: 'CI' on: push: - branches: [ master ] + branches: [master] pull_request: jobs: flake8: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: set up python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: '3.12' - name: install dependencies run: python -m pip install flake8 - name: lint with flake8 @@ -22,14 +22,14 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - pythonversion: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9'] + pythonversion: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: set up python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.pythonversion }} - name: install dependencies - run: "python -m pip install -r requirements-tests.txt -e ." + run: 'python -m pip install -r requirements-tests.txt -e .' - name: test with pytest run: py.test --cov-fail-under=50 --cov=shentry --cov-report=term-missing tests/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2744eb9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -dist: precise -language: python -python: - - "2.6" - - "2.7" - - "3.5" - - "3.6" -install: - - "pip install -r requirements-tests.txt" - - "pip install ." -script: - - "py.test --cov-fail-under=50 --cov=shentry --cov-report=term-missing tests/" - - "if python -c 'import sys; exit(1 if sys.version_info < (2, 7) else 0)' ; then flake8 shentry.py ; else echo 'flake8 is broken on py26'; fi" -env: - - TZ=UTC diff --git a/README.md b/README.md index 0281c28..f4f09ea 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +# Shentry + +[![Build Status](https://travis-ci.com/EasyPost/shentry.svg?branch=master)](https://travis-ci.com/EasyPost/shentry) + **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, @@ -5,25 +9,6 @@ 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 +19,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:priv@app.getsentry.com/id +```sh +SHELL_SENTRY_DSN=https://pub:priv@app.getsentry.com/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:priv@app.getsentry.com/id - SHELL=/usr/local/bin/shentry +```sh +SHELL_SENTRY_DSN=https://pub:priv@app.getsentry.com/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). diff --git a/setup.py b/setup.py index 09efe57..c44ddb0 100755 --- a/setup.py +++ b/setup.py @@ -2,7 +2,6 @@ from setuptools import setup - setup( name="shentry", version="0.4.0", @@ -11,10 +10,10 @@ 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=">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4", classifiers=[ "Development Status :: 3 - Alpha", "Environment :: Console", @@ -25,8 +24,12 @@ "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)", - ] + ], )