Beispiel #1
0
def validate_content_length():
    if cfg.getint('io', 'max_content_length') < request.content_length:
        abort(413)
Beispiel #2
0
from ConfigParser import NoOptionError, NoSectionError
import logging
import random
import socket
import sys

from blueprint import cfg

try:
    host, port = cfg.get('statsd', 'host'), cfg.getint('statsd', 'port')
except (NoOptionError, NoSectionError, ValueError):
    host = port = None


def timing(stat, time, sample_rate=1):
    _send({stat: '{0}|ms'.format(time)}, sample_rate)


def increment(stats, sample_rate=1):
    update(stats, 1, sample_rate)


def decrement(stats, sample_rate=1):
    update(stats, -1, sample_rate)


def update(stats, delta=1, sample_rate=1):
    if type(stats) is not list:
        stats = [stats]
    _send(dict([(stat, '{0}|c'.format(delta)) for stat in stats]), sample_rate)
def validate_content_length():
    if cfg.getint('io', 'max_content_length') < request.content_length:
        abort(413)