skip to navigation
skip to content

ratchet 0.3.1 generic python library

Latest Version: 0.4.1

pyratchet is a generic library for reporting exceptions and other messages to

import ratchet, sys
ratchet.init('YOUR_ACCESS_TOKEN', 'production')  # access_token, environment

except IOError:
    ratchet.report_message('Got an IOError in the main loop', 'warning')
    # catch-all


pyratchet requires:

  • Python 2.6 or 2.7
  • requests 0.12+
  • a account


Install using pip:

pip install ratchet


For generic Python or a non-Django/non-Pyramid framework, follow these instructions:

Somewhere in your initialization code, call ratchet.init() with your access_token:

ratchet.init('YOUR_ACCESS_TOKEN_HERE', environment='production')

Other options can be passed as keyword arguments. See the reference below for all options.

If you are integrating with Django, follow these instructions:

  1. In your, add 'ratchet.contrib.django.middleware.RatchetNotifierMiddleware' as the last item in MIDDLEWARE_CLASSES:

        # ... other middleware classes ...
  2. Add these configuration variables in

    RATCHET = {
        'access_token': 'YOUR_ACCESS_TOKEN_HERE',
        'environment': 'development' if DEBUG else 'production',
        'branch': 'master',
        'root': '/absolute/path/to/code/root',

If you are integrating with Pyramid, follow these instructions:

  1. In your ini file (e.g. production.ini), add ratchet.contrib.pyramid to the end of your pyramid.includes:

    pyramid.includes =
  2. Add these ratchet configuration variables:

    ratchet.access_token = YOUR_ACCESS_TOKEN_HERE
    ratchet.environment = production
    ratchet.branch = master
    ratchet.root = %(here)s


The Django and Pyramid integration will automatically report uncaught exceptions to Ratchet.

Call ratchet.report_exc_info() to report an exception, or ratchet.report_message() to report an arbitrary string message. See the docstrings for more info.

Configuration reference

Access token from your project

One of:

  • blocking – runs in main thread
  • thread – spawns a new thread
  • agent – writes messages to a log file for consumption by ratchet-agent

default: thread

Environment name. Any string up to 255 chars is OK. For best results, use “production” for your production environment.
Absolute path to the root of your application, not including the final /.

Name of the checked-out branch.

default: master

If handler is agent, the path to the log file. Filename must end in .ratchet

URL items are posted to.



List of field names to scrub out of POST. Values will be replaced with astrickses. If overridiing, make sure to list all fields you want to scrub, not just fields you want to add to the default. Param names are converted to lowercase before comparing against the scrub list.

default ['passwd', 'password', 'secret']

Developer Resources

Get in touch! We’d love to hear what you think and we’re happy to help.

File Type Py Version Uploaded on Size
ratchet-0.3.1.tar.gz (md5) Source 2013-01-11 10KB
  • Downloads (All Versions):
  • 63 downloads in the last day
  • 365 downloads in the last week
  • 1452 downloads in the last month