<commit_before>#!/usr/bin/env python
# coding: utf-8

import logging
import logging.handlers
import pickle
import optparse
import ConfigParser

import syncer
from mail import send_error_mail_and_log

def read_timestamp(path):
    """Reads the timestamp (seconds since epoc) of the last sync."""
    try:
        with open(path, "r") as f:
            lastrun = pickle.load(f)
    except IOError as e:
        # this should only occur on the first run of this script
        # if the pickled timestamp is not present yet
        logging.warning("Failed to read timestamp. %s", e.args[1])
        lastrun = 0
    return lastrun

def save_timestamp(path, lastrun):
    with open(path, "w") as f:
        pickle.dump(lastrun, f)

def setup_logging(config):
    logging.basicConfig(level=config.getint('GLOBAL', 'Loglevel'))
    logger = logging.getLogger()
    smtp_handler = logging.handlers.SMTPHandler(
        mailhost=(config.get("MAIL", "Server"), config.get("MAIL", "Port")),
        fromaddr=config.get("MAIL", "Sender"),
        toaddrs=config.get("MAIL", "AdminMail"),
        subject="OX Sync error!",
        credentials=(config.get("MAIL", "User"), config.get("MAIL", "Password")),
        secure=()
    )
    smtp_handler.setLevel(logging.ERROR)
    logger.addHandler(smtp_handler)
<commit_msg>Fixed: Removed unneeded import<commit_after>#!/usr/bin/env python
# coding: utf-8

import logging
import logging.handlers
import pickle
import optparse
import ConfigParser

import syncer

def read_timestamp(path):
    """Reads the timestamp (seconds since epoc) of the last sync."""
    try:
        with open(path, "r") as f:
            lastrun = pickle.load(f)
    except IOError as e:
        # this should only occur on the first run of this script
        # if the pickled timestamp is not present yet
        logging.warning("Failed to read timestamp. %s", e.args[1])
        lastrun = 0
    return lastrun

def save_timestamp(path, lastrun):
    with open(path, "w") as f:
        pickle.dump(lastrun, f)

def setup_logging(config):
    logging.basicConfig(level=config.getint('GLOBAL', 'Loglevel'))
    logger = logging.getLogger()
    smtp_handler = logging.handlers.SMTPHandler(
        mailhost=(config.get("MAIL", "Server"), config.get("MAIL", "Port")),
        fromaddr=config.get("MAIL", "Sender"),
        toaddrs=config.get("MAIL", "AdminMail"),
        subject="OX Sync error!",
        credentials=(config.get("MAIL", "User"), config.get("MAIL", "Password")),
        secure=()
    )
    smtp_handler.setLevel(logging.ERROR)
    logger.addHandler(smtp_handler)

{'fraction_non_alphanumeric': 0.12809597523219815, 'fraction_numerical': 0.0023219814241486067, 'mean_word_length': 3.322742474916388, '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': '1279900', 'n_tokens_mistral': 809, 'n_tokens_neox': 805, 'n_words': 217}