<commit_before># -*- coding: utf-8 -*-
import smtplib
from email.mime.text import MIMEText
from imaplib import IMAP4
import socket
import logging
import time

class mail:
    def __init__(self):
        socket.setdefaulttimeout(10)

    def run(self, config):
        ret = { 'ok': False, 'message': '' }

        # Define content (subject and body)
        content = 'TEST-{0}'.format(time.time())

        # Create the message to send
        message = MIMEText(content)
        message['Subject'] = content
        message['From'] = config['smtp']['user']
        message['To'] = config['smtp']['to']

        # Try to send the mail
        try:
            smtp = smtplib.SMTP(config['smtp']['host'], config['smtp']['port'])
            smtp.starttls()
            smtp.login(config['smtp']['user'], config['smtp']['pass'])
            #smtp.sendmail(config['smtp']['from'], [config['smtp']['to']], message.as_string())
            smtp.quit()
        except:
            ret['ok'] = None
            ret['message'] = 'Cannot send email'
            return ret

        time.sleep(config.get('wait', 10))

        try:
            # Connect and fetch messages
            imap = IMAP4(config['imap']['host'])
            imap.starttls()
            imap.login(config['imap']['user'], config['imap']['pass'])
            imap.select('INBOX')
            typ, data = imap.search(None, 'SUBJECT "{0}"'.format(content))

            # Check if there's any message matching
            if data[0].split():
                ret['ok'] = True
                ret['message'] = 'OK'
            else:<commit_msg>Fix mail test<commit_after># -*- coding: utf-8 -*-
import smtplib
from email.mime.text import MIMEText
from imaplib import IMAP4
import socket
import logging
import time

class mail:
    def __init__(self):
        socket.setdefaulttimeout(10)

    def run(self, config):
        ret = { 'ok': False, 'message': '' }

        # Define content (subject and body)
        content = 'TEST-{0}'.format(time.time())

        # Create the message to send
        message = MIMEText(content)
        message['Subject'] = content
        message['From'] = config['smtp']['user']
        message['To'] = config['smtp']['to']

        # Try to send the mail
        try:
            smtp = smtplib.SMTP(config['smtp']['host'], config['smtp']['port'])
            smtp.starttls()
            smtp.login(config['smtp']['user'], config['smtp']['pass'])
            smtp.sendmail(config['smtp']['from'], [config['smtp']['to']], message.as_string())
            smtp.quit()
        except:
            ret['ok'] = None
            ret['message'] = 'Cannot send email'
            return ret

        time.sleep(config.get('wait', 10))

        try:
            # Connect and fetch messages
            imap = IMAP4(config['imap']['host'])
            imap.starttls()
            imap.login(config['imap']['user'], config['imap']['pass'])
            imap.select('INBOX')
            typ, data = imap.search(None, 'SUBJECT "{0}"'.format(content))

            # Check if there's any message matching
            if data[0].split():
                ret['ok'] = True
                ret['message'] = 'OK'
            else:
{'fraction_non_alphanumeric': 0.16297912122156435, 'fraction_numerical': 0.0062324711748208165, 'mean_word_length': 2.0895091434071222, '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': '334076', 'n_tokens_mistral': 961, 'n_tokens_neox': 921, 'n_words': 217}