dsnrun
Ad hoc utility to rerun a Python script, but with the sentry_sdk initialized
to a specific DSN.
Bring the awesome experience of your error tracking software to ad hoc scripts and tools, non-production scripts and scripts that you cannot easily edit.
Installation & Usage
$ pip install dsnrun
[...]
$ dsnrun -h
Usage: dsnrun [dsn] [-m module | filename] [args...]
To use this, just rewrite your python invocations, i.e.
# normal Python
$ python -m failingmodule
[..stacktrace..]
# becomes
$ dsnrun -m failingmodule
# normal Python
$ python /tmp/failingmodule.py
[..stacktrace..]
# becomes
$ dsnrun /tmp/failingmodule.py
Now, visit your Error Tracker and get a much prettier stacktrace (including local variables).
Rationale
At Bugsink, we like our Error Tracking so much, that we even use it for local development. (Why wouldn't we: setup is trivial).
If you like Python, you probably do a lot with Python, including things for which you dind't plan on setting up your Error Tracker. Still, you occasionally mess up, leading to a stack trace on-screen.
What if that stacktrace was as awesome as the one in your error tracker?
Features
- Because we use
runpyto run the script, it should work with any Python script that you can run withpython -morpython filename.py. i.e. anyif __name__ == '__main__':block will still work as expected.
Limitations
Don't use this to set up sentry_dsn for your actual production code. We
shouldn't have to explain why, but the gist of it is: There may very well be
edge cases that trip this thing up, and why would you break production if you
can just add a few lines to your actual production code?
These are current limitations, meaning we might as well improve the script if it turns out to be useful:
-
the on-screen (printed) stacktrace for
dsnrunis not equal to the regular-python version; it also containsdsnrunitself and the functions it invokes. The event as sent to your DSN does not contain these though (we prune it). -
dsnis the only currently supported argument tosentry_sdk.init. For future versions I'll put in the work of translating CLI args to SDK args. -
dsnrun manually patches
sys.argvsuch that the invoked script does not getdsnrun's arguments passed to it. This "seems to work" (but may not generally work). However, I did not find a way to "properly do this". See https://bugs.python.org/issue26388 -
If you mistype the thing-to-run you'll send an
ImportErrorto your DSN. This is not filtered out (yet). Examples:
ImportError: No module named nosuchmodule
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/nosuchfile.py'
Metadata
Release files for dsnrun 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dsnrun-0.2.0.tar.gz | 6.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dsnrun-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.7 kB
Release files / dsnrun-0.2.0.tar.gz
| Download URL | dsnrun-0.2.0.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f8c324c509d9668bfdbf65bae13a315beda3e43a2a173f19453f4b0d7549f297
|
|
BLAKE2b-256 checksum How to use checksums |
b431e04fc64c0f525aa4f12d4a9a6a2b46ecb568b8a8eca94e59bc6319fb5d0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / dsnrun-0.2.0-py3-none-any.whl
| Download URL | dsnrun-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
127b4175b41da814bd50c2043c44a3cd1fb5499c0d557e6ee32c5c288624e0ce
|
|
BLAKE2b-256 checksum How to use checksums |
108b0d8d42ba4dbd0e1c43835ac978b7d8fef91e1fd2c1f34ad11da1eaf99289
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Security for dsnrun 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.