<commit_before>from __future__ import absolute_import

import os
import sys
import types

DEFAULT_APPS = ("django.contrib.auth",
                "django.contrib.contenttypes",
                "django.contrib.sessions",
                "django.contrib.admin",
                "django.contrib.admindocs",
                "djcelery")

DEFAULTS = {"ROOT_URLCONF": "djcelery.monproj.urls",
            "DATABASE_ENGINE": "sqlite3",
            "DATABASE_NAME": "djcelerymon.db",
            "DATABASES": {"default": {
                            "ENGINE": "django.db.backends.sqlite3",
                            "NAME": "djcelerymon.db"}},
            "BROKER_URL": "amqp://",
            "SITE_ID": 1,
            "INSTALLED_APPS": DEFAULT_APPS,
            "DEBUG": False}


def default_settings(name="__default_settings__"):
    c = type(name, (types.ModuleType, ), DEFAULTS)(name)
    c.__dict__.update({"__file__": __file__})
    sys.modules[name] = c
    return name


def configure():
    from celery import current_app
    from celery.loaders.default import DEFAULT_CONFIG_MODULE
    from django.conf import settings

    if not settings.configured:
        if current_app.loader.configured:
            settings_module = os.environ.get("CELERY_CONFIG_MODULE",
                                             DEFAULT_CONFIG_MODULE)
        else:
            settings_module = default_settings()
        settings.configure(SETTINGS_MODULE=settings_module,
                           **dict(DEFAULTS, **current_app.loader.conf))
        settings.DEBUG = True


def run_monitor(argv):
    from .management.commands import djcelerymon
    djcelerymon.Command().run_from_argv([argv[0], "djcelerymon"] + argv[1:])
<commit_msg>djcelerymon command always ran with DEBUG=True.  Closes #111<commit_after>from __future__ import absolute_import

import os
import sys
import types

from celery.app.defaults import str_to_bool

DEFAULT_APPS = ("django.contrib.auth",
                "django.contrib.contenttypes",
                "django.contrib.sessions",
                "django.contrib.admin",
                "django.contrib.admindocs",
                "djcelery")

DEFAULTS = {"ROOT_URLCONF": "djcelery.monproj.urls",
            "DATABASE_ENGINE": "sqlite3",
            "DATABASE_NAME": "djcelerymon.db",
            "DATABASES": {"default": {
                            "ENGINE": "django.db.backends.sqlite3",
                            "NAME": "djcelerymon.db"}},
            "BROKER_URL": "amqp://",
            "SITE_ID": 1,
            "INSTALLED_APPS": DEFAULT_APPS,
            "DEBUG": str_to_bool(os.environ.get("DJCELERYMON_DEBUG", False))}


def default_settings(name="__default_settings__"):
    c = type(name, (types.ModuleType, ), DEFAULTS)(name)
    c.__dict__.update({"__file__": __file__})
    sys.modules[name] = c
    return name


def configure():
    from celery import current_app
    from celery.loaders.default import DEFAULT_CONFIG_MODULE
    from django.conf import settings

    if not settings.configured:
        if current_app.loader.configured:
            settings_module = os.environ.get("CELERY_CONFIG_MODULE",
                                             DEFAULT_CONFIG_MODULE)
        else:
            settings_module = default_settings()
        settings.configure(SETTINGS_MODULE=settings_module,
                           **dict(DEFAULTS, **current_app.loader.conf))


def run_monitor(argv):
    from .management.commands import djcelerymon
    djcelerymon.Command().run_from_argv([argv[0], "djcelerymon"] + argv[1:])

{'fraction_non_alphanumeric': 0.1124859392575928, 'fraction_numerical': 0.003655793025871766, 'mean_word_length': 2.2935185185185185, 'pattern_counts': {'":': 24, '<': 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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '178634', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1048, 'n_words': 188}