<commit_before>"""
A tiny app that checks for a status message.
"""

from django.conf import settings
import logging
import os
import sys

from util.cache import cache

log = logging.getLogger(__name__)

def get_site_status_msg():
    """
    Look for a file settings.STATUS_MESSAGE_PATH.  If found, return the
    contents.  Otherwise, return None.  Caches result for 10 seconds, per-machine.

    If something goes wrong, returns None.  ("is there a status msg?" logic is
    not allowed to break the entire site).
    """
    cache_time = 10
    try:
        key = ','.join([settings.HOSTNAME, settings.STATUS_MESSAGE_PATH])
        content = cache.get(key)
        if content == '':
            # cached that there isn't a status message
            return None

        if content is None:
            # nothing in the cache, so check the filesystem
            if os.path.isfile(settings.STATUS_MESSAGE_PATH):
                with open(settings.STATUS_MESSAGE_PATH) as f:
                    content = f.read()
            else:
                # remember that there isn't anything there
                cache.set(key, '', cache_time)
                content = None

        return content
    except:
        log.debug("Error while getting a status message: {0}".format(sys.exc_info()))
        return None<commit_msg>get rid of caching--unneeded complexity.<commit_after>"""
A tiny app that checks for a status message.
"""

from django.conf import settings
import logging
import os
import sys

from util.cache import cache

log = logging.getLogger(__name__)

def get_site_status_msg():
    """
    Look for a file settings.STATUS_MESSAGE_PATH.  If found, return the
    contents.  Otherwise, return None.

    If something goes wrong, returns None.  ("is there a status msg?" logic is
    not allowed to break the entire site).
    """
    try:
        content = None
        if os.path.isfile(settings.STATUS_MESSAGE_PATH):
            with open(settings.STATUS_MESSAGE_PATH) as f:
                content = f.read()

        return content
    except:
        log.debug("Error while getting a status message: {0}".format(sys.exc_info()))
        return None
{'fraction_non_alphanumeric': 0.08440959409594095, 'fraction_numerical': 0.0027675276752767526, 'mean_word_length': 2.3943661971830985, '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': '2628195', 'n_tokens_mistral': 593, 'n_tokens_neox': 572, 'n_words': 216}