05/04/22 - 15h40

master
ChérifBALDE 2022-04-05 15:44:38 +02:00 committed by cherif
parent 2cb62b2e91
commit 5fc7af37a1
2 changed files with 139 additions and 116 deletions

View File

@ -5,6 +5,9 @@ from email.mime.base import MIMEBase
from email import encoders from email import encoders
import locale import locale
import datetime import datetime
import inspect
import sys, os
import prj_common as mycommon
locale.setlocale(category=locale.LC_ALL, locale='fr_FR.utf8') locale.setlocale(category=locale.LC_ALL, locale='fr_FR.utf8')
smtp_address = 'smtp.ionos.fr' smtp_address = 'smtp.ionos.fr'
@ -27,6 +30,7 @@ password = 'cYa1pk56Zx7EzKmg'
def send_user_account_mail(message, account_mail): def send_user_account_mail(message, account_mail):
try:
tomorrow = datetime.date.today() + datetime.timedelta(days=1) tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A") tomorrow_day = tomorrow.strftime("%A")
@ -106,10 +110,19 @@ Pour valider votre compte, veuillez cliquer sur le lien <font color="green">ci-d
server.login(user, password) server.login(user, password)
server.sendmail(sender, toaddrs, msg.as_string()) server.sendmail(sender, toaddrs, msg.as_string())
print("mail successfully sent to "+str(toaddrs)) mycommon.myprint("mail successfully sent to "+str(toaddrs))
return True
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible d'envoyer l'email de notification "
def send_partner_account_mail(message, account_mail): def send_partner_account_mail(message, account_mail):
try:
tomorrow = datetime.date.today() + datetime.timedelta(days=1) tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A") tomorrow_day = tomorrow.strftime("%A")
@ -173,4 +186,11 @@ def send_partner_account_mail(message, account_mail):
server.sendmail(sender, toaddrs, msg.as_string()) server.sendmail(sender, toaddrs, msg.as_string())
print("mail successfully sent") print("mail successfully sent")
return True
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible d'envoyer l'email de notification"

View File

@ -68,7 +68,8 @@ def get_recherche_gle_class(sentence):
return insertObject return insertObject
except Exception as e: except Exception as e:
mycommon.myprint(e) exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False return False
@ -94,7 +95,8 @@ def get_class_by_list_attr(attribut, list_values):
return insertObject return insertObject
except Exception as e: except Exception as e:
mycommon.myprint(e) exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False return False
@ -119,7 +121,8 @@ def update_class_by_attribut(objId, attribut, value):
except Exception as e: except Exception as e:
mycommon.myprint(e) exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False return False