Commit fe285619 authored by Nicolas Ollinger's avatar Nicolas Ollinger

ajout des noms de fichiers dans les log

parent 767c15b6
.DS_Store .DS_Store
__pycache__ __pycache__
*.swp
2020-06-07 14:37:55,068 ==== Début du mailing ==== 2020-06-07 15:00:57,650 ==== Début du mailing ====
2020-06-07 14:37:55,276 alice.demo@mailinator.com: OK 2020-06-07 15:00:57,835 alice.demo@mailinator.com <- 104.pdf: OK
2020-06-07 14:37:55,451 bob.demo@mailinator.com: OK 2020-06-07 15:00:57,996 bob.demo@mailinator.com <- 104.pdf: OK
2020-06-07 14:37:55,458 ==== Fin du mailing ==== 2020-06-07 15:00:58,003 ==== Fin du mailing ====
2020-06-07 14:53:46,688 ==== Début du mailing ====
2020-06-07 14:54:29,406 ==== Début du mailing ====
2020-06-07 14:54:29,609 alice.demo@mailinator.com: OK
2020-06-07 14:54:29,779 bob.demo@mailinator.com: OK
2020-06-07 14:54:29,786 ==== Fin du mailing ====
2020-06-07 14:55:13,281 ==== Début du mailing ====
2020-06-07 14:55:13,471 alice.demo@mailinator.com: OK
2020-06-07 14:55:13,641 bob.demo@mailinator.com: OK
2020-06-07 14:55:13,839 nopid@free.fr: OK
2020-06-07 14:55:13,846 ==== Fin du mailing ====
...@@ -49,9 +49,9 @@ def envoie(serveur,port,login,mdp,sujet,corps,emet,dest,dobcc,file_path,filename ...@@ -49,9 +49,9 @@ def envoie(serveur,port,login,mdp,sujet,corps,emet,dest,dobcc,file_path,filename
server.login(login,mdp) server.login(login,mdp)
try: try:
server.send_message(msg) server.send_message(msg)
logging.info('{}: OK'.format(dest)) logging.info('{} <- {}: OK'.format(dest,file_path))
except Exception as e: except Exception as e:
logging.error('{} : {}'.format(dest,str(e))) logging.error('{} <- {}: {}'.format(dest,file_path,str(e)))
print('ERROR ON {}'.format(dest)) print('ERROR ON {}'.format(dest))
logging.basicConfig(filename='mailing.log',level=logging.DEBUG,format='%(asctime)s %(message)s') logging.basicConfig(filename='mailing.log',level=logging.DEBUG,format='%(asctime)s %(message)s')
...@@ -59,7 +59,7 @@ logging.info('==== Début du mailing ====') ...@@ -59,7 +59,7 @@ logging.info('==== Début du mailing ====')
with open('mailing.csv',newline='') as f: with open('mailing.csv',newline='') as f:
reader=csv.reader(f) reader=csv.reader(f)
for row in reader: for row in reader:
print('{}...'.format(row[0])) print('{} <- {}...'.format(row[0],row[1]))
envoie(conf['server']['hostname'],int(conf['server']['port']),conf['server']['login'],conf['server']['passwd'], envoie(conf['server']['hostname'],int(conf['server']['port']),conf['server']['login'],conf['server']['passwd'],
sujet,texte.format(*row[3:]),conf['mail']['sender'],row[0],conf['mail']['bcc']=='true',row[1],row[2]) sujet,texte.format(*row[3:]),conf['mail']['sender'],row[0],conf['mail']['bcc']=='true',row[1],row[2])
logging.info('==== Fin du mailing ====') logging.info('==== Fin du mailing ====')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment