<commit_before>import logging.handlers

from allocations import allocations
from health import health
from shards import shards
from indices import indices
from mailer import mail
from master import get_master
from nodes import nodes
from os import mkdir

try:
    mkdir("logs")
except IOError:
    pass

LOG_FILENAME = "logs/es_monitor.log"
LOG_MSG_FORMAT = "%(asctime)s %(name)-12s %(levelname)-8s %(message)s"
LOG_DATE_FORMAT = "%d-%m-%Y %H:%M:%S"

# Setup default stream logger
logging.basicConfig(level=logging.INFO, format=LOG_MSG_FORMAT, datefmt=LOG_DATE_FORMAT)

# Setup rotating log file handler
rotating_file_handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=1e7, backupCount=20)
rotating_file_handler.setFormatter(logging.Formatter(fmt=LOG_MSG_FORMAT, datefmt=LOG_DATE_FORMAT))
logging.root.addHandler(rotating_file_handler)

try:
    import simplejson as json
except ImportError:
    import json

with open("clusters.json") as f:<commit_msg>except OSError if the dir already exists<commit_after>import logging.handlers

from allocations import allocations
from health import health
from shards import shards
from indices import indices
from mailer import mail
from master import get_master
from nodes import nodes
from os import mkdir

try:
    mkdir("logs")
except OSError:
    pass

LOG_FILENAME = "logs/es_monitor.log"
LOG_MSG_FORMAT = "%(asctime)s %(name)-12s %(levelname)-8s %(message)s"
LOG_DATE_FORMAT = "%d-%m-%Y %H:%M:%S"

# Setup default stream logger
logging.basicConfig(level=logging.INFO, format=LOG_MSG_FORMAT, datefmt=LOG_DATE_FORMAT)

# Setup rotating log file handler
rotating_file_handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=1e7, backupCount=20)
rotating_file_handler.setFormatter(logging.Formatter(fmt=LOG_MSG_FORMAT, datefmt=LOG_DATE_FORMAT))
logging.root.addHandler(rotating_file_handler)

try:
    import simplejson as json
except ImportError:
    import json

with open("clusters.json") as f:
{'fraction_non_alphanumeric': 0.08717688798783578, 'fraction_numerical': 0.007095793208312215, 'mean_word_length': 6.680933852140078, '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': '2161925', 'n_tokens_mistral': 640, 'n_tokens_neox': 625, 'n_words': 167}