Skip to main content

A utility that cures the horrible traceback displays in Python, making them more readable.

Project description

TBVaccine is a utility that pretty-prints Python tracebacks. It automatically highlights lines you care about and deemphasizes lines you don’t, and colorizes the various elements in a traceback to make it easier to parse, like so:

misc/screenshot.png

Installation

To install, use pip:

pip install tbvaccine

You are done!

Usage as a command-line utility

TBVaccine can be used from the command line. Just pipe STDERR into it from the program you want to watch:

./myscript.py 2>&1 | tbvaccine

And all the tracebacks will now be pretty!

Usage as a Python library

There are various ways to use TBVaccine as a Python library.

Initialize it like so:

from tbvaccine import TBVaccine
tbv = TBVaccine(
    code_dir="/my/code/dir",
    isolate=True
)

code_dir marks the directory we code about. Files under that directory that appear in the traceback will be highlighted. If not passed, the current directory, as returned by os.getcwd() will be used.

If isolate is False, all lines are colorized, and code_dir is ignored.

To use it in an except block:

from tbvaccine import TBVaccine
try:
    some_stuff()
except:
    print(TBVaccine().format_exc())

I’ll tell you about the other ways later.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tbvaccine-0.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

tbvaccine-0.0.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file tbvaccine-0.0.1.tar.gz.

File metadata

  • Download URL: tbvaccine-0.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tbvaccine-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5add6a11d8206bf80cd93d64003d2f7a9ec0179cd22981a25bdd91aeb13f46e3
MD5 931c258c9917a4dd73948775abbe3d76
BLAKE2b-256 14c778ca596a063cc3b146fbab0bd9456a1054611c03f5ca618952533c37d601

See more details on using hashes here.

File details

Details for the file tbvaccine-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for tbvaccine-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5789f336b04ad8a5dceda9f6cf14c4c7612145ba241618e5cf8610f4e2302f33
MD5 2c22aa84577aff68d51a89b7861e5f2f
BLAKE2b-256 05fbe076eb5c862121b547afaad17387a3f10d36d993ac125515efa637186c0e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page