This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!
Project Description

Generic helpers I wish existed or am constantly copying into my Python projects.

env

Get information about your environment variables.

.get(key, ...)

You can use env.get as a drop-in replacement for os.environ.get. It acts the same but is smarter about types and has extra magic for ENVIRONMENT based settings:

from project_runpy import env

env.get('DATABASE_URL')  # get an environment variable
env.get('DATABASE_URL', 'sqlite:///:memory:')  # provide a default
env.get('DEBUG', True)  # default can be bool
env.get('WORKERS', 10)  # default can be other types too, like int
env.get('DEBUG', True, type_func=bool)  # explicitly get bool

If additional kwargs are specified, they will become the default if ENVIRONMENT matches the key:

from project_runpy import env

env.get('WORKERS', 10, DEV=1)  # if ENVIRONMENT == DEV: default = 1
env.get('DEBUG', FALSE, type_func=bool, TEST=False)  # combine it

.require(key, ...)

If you want to be extra strict/cautious, you can raise an exception if the environment variable was not set by using .require instead of .get.

Demo:

>>> from project_runpy import env
>>> env.require('SHIRTSNSHOES')
ImproperlyConfigured: Environment variable not found: SHIRTSNSHOES

ColorizingStreamHandler

Logging handler that produces colorized console output

Usage:

import logging

from project_runpy import ColorizingStreamHandler

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.addHandler(ColorizingStreamHandler())

Django:

LOGGING = {

    ...

    'handlers': {

        ...

        'console': {
            'level': 'DEBUG',
            'class': 'project_runpy.ColorizingStreamHandler',
        },
    },

    ...

}

ReadableSqlFilter

A logging filter designed to make the django.db.backends console output more readable. This is an alternate to Django Debug Toolbar’s SQL panel (which, you should be using too)

Turns:

(0.002) SELECT "tx_elevators_building"."id", "tx_elevators_building"."elbi",
"tx_elevators_building"."name_1", "tx_elevators_building"."name_2",
"tx_elevators_building"."address_1", "tx_elevators_building"."address_2",
"tx_elevators_building"."city", "tx_elevators_building"."zip_code",
"tx_elevators_building"."county", "tx_elevators_building"."owner",
"tx_elevators_building"."contact", "tx_elevators_building"."latitude",
"tx_elevators_building"."longitude" FROM "tx_elevators_building" LIMIT 21;
args=()

Into:

(0.002) SELECT ... FROM "tx_elevators_building" LIMIT 21; args=()

To install, edit your Django settings:

LOGGING = {
    ...
    'filters': {
        'readable_sql': {
            '()': 'project_runpy.ReadableSqlFilter',
        },
    },
    'loggers': {
        'django.db.backends': {
            'filters': ['readable_sql'],
            ...
        },
    },
    ...
}

About

Inspired by dj-settings-helpers, ansistrm.py, and tornado’s define.

Release History

Release History

0.3.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1-dev.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
project_runpy-0.3.1-py2.py3-none-any.whl (8.1 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Aug 18, 2014
project_runpy-0.3.1.tar.gz (8.9 kB) Copy SHA256 Checksum SHA256 Source Aug 18, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting