<commit_before>#enconding:utf-8
import logging

import yaml
from raven import Client
from raven.handlers.logging import SentryHandler
from raven.conf import setup_logging

import utils


with open('prod.yml') as config_file:
    config = yaml.load(config_file.read())


if 'sentry' in config:
    client = Client(config['sentry'], auto_log_stacks=True)
    handler = SentryHandler(client)
    setup_logging(handler)
else:
    client = None
    logging.info("Sentry.io not loaded")


def report_error(fn):
    def wrapper(*args, **kwargs):
        try:
            fn(*args, **kwargs)
        except Exception as e:
            r2t = utils.Reddit2TelegramSender(config['telegram_dev_chat'], config)
            r2t.send_text(str(e))
            if client:  # has sentry instance
                client.captureException()
            else:
                logging.exception("Exception Ignored.")
    return wrapper<commit_msg>Reporting submodule name.<commit_after>#enconding:utf-8
import logging
import traceback
import sys

import yaml
from raven import Client
from raven.handlers.logging import SentryHandler
from raven.conf import setup_logging

import utils


with open('prod.yml') as config_file:
    config = yaml.load(config_file.read())


if 'sentry' in config:
    client = Client(config['sentry'], auto_log_stacks=True)
    handler = SentryHandler(client)
    setup_logging(handler)
else:
    client = None
    logging.info('Sentry.io not loaded')


def send_report_to_dev_chat(exc):
    r2t = utils.Reddit2TelegramSender(config['telegram_dev_chat'], config)
    local_vars = sys.exc_info()[2].tb_next.tb_frame.f_locals
    subreddit = local_vars['subreddit']
    report = '{subreddit}\n______\n{exeption}'.format(
        subreddit=subreddit,
        exeption=str(exc)
    )
    r2t.send_text(report)


def report_error(fn):
    def wrapper(*args, **kwargs):
        try:
            fn(*args, **kwargs)
        except Exception as e:
            send_report_to_dev_chat(e)
            if client:  # has sentry instance
                client.captureException()
            else:
                logging.exception('Exception Ignored.')
    return wrapper
{'fraction_non_alphanumeric': 0.10027726432532348, 'fraction_numerical': 0.004158964879852125, 'mean_word_length': 3.069548872180451, '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': '849179', 'n_tokens_mistral': 673, 'n_tokens_neox': 662, 'n_words': 152}