Пример #1
0
def get_attach(msg):  # toate atasamentele acestui mail
    global gl_input_dir, modMail, param, glreaded_now, dJob_id_contor
    glreaded_now = 0
    job_id = job_name_2_job_id()
    if job_id == 0 :  # e un mail din afara sistemului...de ex-- de la banica ptr mine
        return  # nu mna interes atasamnentele lui
    for part in msg.walk():
        if modMail == 'mod_in_fis':
            filename = part.get_filename()
            if filename:
                fp = open(gl_input_dir + '//' + filename, 'wb')
                fp.write(part.get_payload(decode=True))
                fp.close()
        else:
            filename = part.get_filename()  # numele atasamentului, nu al fis salvat pe HD
            if filename:
                html = part.get_payload(decode=True)
                try:
                    stare = cv._2prelFis(param, filename, filename, cnx, cursor, 'mod_din_mail', html, job_id)
                    if stare == 'DUBLA':
                        continue
                    elif stare == 'ER':
                        # w cv eronat, ptr o next reluare
                        fp = open(gl_er_dir + '//' + filename, 'wb')
                        fp.write(html)
                        fp.close()
                    else:
                        glreaded_now = glreaded_now + 1
                except:
                    pass
    contor_vechi = dJob_id_contor[job_id]
    contor_nou = contor_vechi + glreaded_now
    upd_contor_cv_dinJob(job_id, contor_nou) 
    dJob_id_contor[job_id] = contor_nou       
    return
Пример #2
0
def main():
    global gl_input_dir, modMail, param, cnx, cursor, dJob_description_id , dJob_id_contor
    userName, passw, dbname, hostname, gl_input_dir, param, modMail, gl_er_dir = _00CitYAML_param_conectBD(dirCrt + '/' + 'CV_html_2_BD.yaml')
    cnx, cursor, iduser, lJobs = _01cit_JOBS(userName, passw, dbname, hostname)
    for id, name, x_mail_user, x_mail_pwd, x_number_cv in lJobs:  #  ptr aflarea CV-nume job(mail)--> nr job--> applicant.job_id
        dJob_description_id[name] = id
    for id, name, x_mail_user, x_mail_pwd, x_number_cv in lJobs:  #  ptr lafarea CV-nume job(mail)--> nr job--> applicant.job_id
        dJob_id_contor[id] = x_number_cv        
    for (id, name, x_mail_user, x_mail_pwd, x_number_cv) in lJobs:
        # glreaded_now = 0
        passwd = base64.b64encode(x_mail_pwd)
        imap_host = 'imap.gmail.com'
        mail = imaplib.IMAP4_SSL(imap_host)
        if modMail != 'mod_din_fis':
            mail.login(x_mail_user, base64.b64decode(passwd))  # base64.b64decode(passwd
            #
            get_mail(mail)  # scot temporar. ptr test
            # server.quit()  # send
        if modMail == 'mod_din_fis':
            lFis = os.listdir(unicode(gl_input_dir, 'utf-8'))  # Changed in version 2.3: On Windows NT/2k/XP and Unix, if path is a Unicode object, the result will be a list of Unicode objects. Undecodable filenames will still be returned as string objects.
            for fis in lFis:
                assert isinstance (cursor, object)
                cv._2prelFis(param, gl_input_dir + '//' + fis, fis, cnx, cursor, 'mod_din_fis', '-', 0)
                
        # mail.logout()
    #======== verif si prelucr eventuale fis eronate(dupa 
    lFis = os.listdir(unicode(gl_er_dir, 'utf-8'))  # Changed in version 2.3: On Windows NT/2k/XP and Unix, if path is a Unicode object, the result will be a list of Unicode objects. Undecodable filenames will still be returned as string objects.
    for fis in lFis:
        stare = cv._2prelFis(param, gl_input_dir + '//' + fis, fis, cnx, cursor, 'mod_din_fis', '-', 0)
        if stare == 'DUBLA':
            continue
        elif stare == 'ER':
            continue  # nu s-a rezolvat
        else:
            # er rezolvata(prin modif programului) - sterg fis din dir cu erori 
            # glreaded_now = glreaded_now + 1 - nu stiu conorul carui job trebui eincrem - as putea pastra job-id in numele fis
            # sterg fis eronat
            os.remove(gl_input_dir + '//' + fis)

 
    cursor.close()
    cnx.close()
    return