<commit_before>"""
raven.contrib.flask
~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import absolute_import

from flask import request
from flask.signals import got_request_exception
from raven.base import Client

class Sentry(object):
    def __init__(self, app=None, client=None, client_cls=Client):
        self.app = app
        self.client = client
        self.client_cls = client_cls

        if app:
            self.init_app(app)

    def handle_exception(self, client):
        def _handle_exception(sender, **kwargs):
            client.create_from_exception(
                exc_info=kwargs.get('exc_info'),
                url=request.url,
                data={
                    'META': request.environ,
                    'GET': request.args,
                    'POST': request.form,
                    'app': sender.name,
                },
            )
        return _handle_exception

    def init_app(self, app):
        if not self.client:<commit_msg>Since raven has a django fallback if the servers are missing, break early if servers are not set in the Flask extension.<commit_after>"""
raven.contrib.flask
~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import absolute_import

from flask import request
from flask.signals import got_request_exception
from raven.base import Client

class Sentry(object):

    def __init__(self, app=None, client=None, client_cls=Client):
        self.app = app
        self.client = client
        self.client_cls = client_cls

        if app:
            self.init_app(app)

    def handle_exception(self, client):
        def _handle_exception(sender, **kwargs):
            client.create_from_exception(
                exc_info=kwargs.get('exc_info'),
                url=request.url,
                data={
                    'META': request.environ,
                    'GET': request.args,
                    'POST': request.form,
                    'app': sender.name,
                },
            )
        return _handle_exception

    def init_app(self, app):
        if not self.client:
            if not app.config.get('SENTRY_SERVERS'):
                raise TypeError('The SENTRY_SERVERS config variable is required.')
{'fraction_non_alphanumeric': 0.10222588623248145, 'fraction_numerical': 0.0032976092333058533, 'mean_word_length': 2.1075544174135725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7035474', 'n_tokens_mistral': 682, 'n_tokens_neox': 643, 'n_words': 188}