<commit_before>#coding: utf-8

from model import Deposit, DB
from Bankmail import *
import sys
import sqlite3
import imaplib
import traceback
from datetime import datetime
from time import sleep

from common.logger import Logger
import config

logger = Logger()
def log(msg):
    return logger.log(msg)
    

def check(user, passwd):
    try:
        i = imaplib.IMAP4_SSL("imap.gmail.com")
        i.login(user, passwd)
    except imaplib.IMAP4.error as ex: ## kannski grípa utar
        log(str(ex))
        sys.exit(1)

    i.select()
    status, response = i.search(None, 'ALL')
    mailids = [int(a) for a in response[0].split()]
    my_mailid = DB.get().max_mailid()
    new_mailids = [a+1 for a in range(my_mailid, max(mailids))]

    for mailid in new_mailids:
        DB.get().add_mailid(mailid)
        f = i.fetch(mailid, '(RFC822)')
        mail = f[1][0][1]
        info = f[1][0][0]
        try:
            b = Bankmail(mail)
            # .new() calls .save() :(
            Deposit.new(b.username, b.amount, "Wire", deposit=True)
            logger.email("Username: {username}\nAmount: {amount}".format(**b.__dict__))
        except NotBankmail as notb:
            log("Skipping {0}: {1}".format(mailid, str(notb)))
            pass<commit_msg>vsk was missing<commit_after>#coding: utf-8

from model import Deposit, DB
from Bankmail import *
import sys
import sqlite3
import imaplib
import traceback
from datetime import datetime
from time import sleep

from common.logger import Logger
import config

logger = Logger()
def log(msg):
    return logger.log(msg)
    

def check(user, passwd):
    try:
        i = imaplib.IMAP4_SSL("imap.gmail.com")
        i.login(user, passwd)
    except imaplib.IMAP4.error as ex: ## kannski grípa utar
        log(str(ex))
        sys.exit(1)

    i.select()
    status, response = i.search(None, 'ALL')
    mailids = [int(a) for a in response[0].split()]
    my_mailid = DB.get().max_mailid()
    new_mailids = [a+1 for a in range(my_mailid, max(mailids))]

    for mailid in new_mailids:
        DB.get().add_mailid(mailid)
        f = i.fetch(mailid, '(RFC822)')
        mail = f[1][0][1]
        info = f[1][0][0]
        try:
            b = Bankmail(mail)
            # .new() calls .save() :(
            Deposit.new(b.username, b.amount, "Wire", deposit=True, vsk=25.5)
            logger.email("Username: {username}\nAmount: {amount}".format(**b.__dict__))
        except NotBankmail as notb:
            log("Skipping {0}: {1}".format(mailid, str(notb)))
            pass
{'fraction_non_alphanumeric': 0.13682965299684544, 'fraction_numerical': 0.015378548895899053, 'mean_word_length': 2.608819345661451, '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': '4784883', 'n_tokens_mistral': 896, 'n_tokens_neox': 884, 'n_words': 220}