<commit_before>import os

from apscheduler.schedulers.blocking import BlockingScheduler
from raven.base import Client as RavenClient

import warner
import archiver
import announcer
import flagger


raven_client = RavenClient()


# When testing changes, set the "TEST_SCHEDULE" envvar to run more often
if os.getenv("TEST_SCHEDULE"):
    schedule_kwargs = {"hour": "*", "minute": "*/10"}
else:
    schedule_kwargs = {"hour": 4}

sched = BlockingScheduler()


@sched.scheduled_job("cron", **schedule_kwargs)
def destalinate_job():
    print("Destalinating")
    if "SB_TOKEN" not in os.environ or "API_TOKEN" not in os.environ:
        print("ERR: Missing at least one Slack environment variable.")
    else:
        try:
            scheduled_warner = warner.Warner()
            scheduled_archiver = archiver.Archiver()
            scheduled_announcer = announcer.Announcer()
            scheduled_flagger = flagger.Flagger()
            print("Warning")
            scheduled_warner.warn()
            print("Archiving")
            scheduled_archiver.archive()
            print("Announcing")
            scheduled_announcer.announce()
            print("Flagging")
            scheduled_flagger.flag()
            print("OK: destalinated")
        except Exception as e:  # pylint: disable=W0703
            raven_client.captureException()
            if not os.getenv('SENTRY_DSN'):
                raise e
    print("END: destalinate_job")


sched.start()<commit_msg>Log in the scheduler instead of print<commit_after>import logging
import os

from apscheduler.schedulers.blocking import BlockingScheduler
from raven.base import Client as RavenClient

import warner
import archiver
import announcer
import flagger


raven_client = RavenClient()

logger = logging.getLogger(__name__)

# When testing changes, set the "TEST_SCHEDULE" envvar to run more often
if os.getenv("TEST_SCHEDULE"):
    schedule_kwargs = {"hour": "*", "minute": "*/10"}
else:
    schedule_kwargs = {"hour": 4}

sched = BlockingScheduler()


@sched.scheduled_job("cron", **schedule_kwargs)
def destalinate_job():
    logger.info("Destalinating")
    if "SB_TOKEN" not in os.environ or "API_TOKEN" not in os.environ:
        logger.error("Missing at least one Slack environment variable.")
    else:
        try:
            warner = warner.Warner()
            archiver = archiver.Archiver()
            announcer = announcer.Announcer()
            flagger = flagger.Flagger()

            logger.info("Warning")
            warner.warn()

            logger.info("Archiving")
            archiver.archive()

            logger.info("Announcing")
            announcer.announce()

            logger.info("Flagging")
            flagger.flag()

            logger.info("OK: destalinated")
        except Exception as e:  # pylint: disable=W0703
            raven_client.captureException()
            if not os.getenv('SENTRY_DSN'):
                raise e
    logger.info("END: destalinate_job")


sched.start()
{'fraction_non_alphanumeric': 0.10204081632653061, 'fraction_numerical': 0.00468384074941452, 'mean_word_length': 2.723536737235367, 'pattern_counts': {'":': 6, '<': 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': '563115', 'n_tokens_mistral': 883, 'n_tokens_neox': 875, 'n_words': 214}