Commit ce5dfc7e authored by Daniel STAN's avatar Daniel STAN

statistiques2.py: templating

On répare l'envoi de mail au passage
parent 22d5baae
Envoyé à disconnect chaque jour
Upload des serveurs (à partir de {{seuil_upload}})
{{upload_srv}}
--
Disconnect team
......@@ -23,6 +23,7 @@ import psycopg2.extras
import smtplib
import gestion.config.upload as upload_config
import gestion.config as config
from gestion import mail as mail_module
ldap = lc_ldap.shortcuts.lc_ldap_readonly()
encoding = "UTF-8"
......@@ -189,27 +190,17 @@ if __name__ == "__main__":
if args.mail:
expediteur = "disconnect@crans.org"
destinataire = "disconnect@crans.org"
message = """From: %(From)s
To: %(To)s
Subject: Statistiques des =?utf-8?q?derni=C3=A8res?= 24h
X-Mailer: /usr/scripts/surveillance/statistiques.py
Content-Type: text/plain; charset="utf-8"
Upload des serveurs (à partir de %(seuil_upload)s)
%(upload_srv)s
--
statistiques.py
"""
corps = message % {
'From': expediteur,
'To': destinataire,
'upload_srv': fetched_upload_srv,
'seuil_upload': upload_config.pretty_seuil,
}
# Testing purpose:
# destinataire = "your.mail@crans.org"
corps = mail_module.generate('upload_stats',
{
'from': expediteur,
'to': destinataire,
'upload_srv': fetched_upload_srv,
'seuil_upload': upload_config.pretty_seuil,
}).as_string()
mail = smtplib.SMTP('localhost')
mail.sendmail(expediteur, expediteur, corps)
mail.sendmail(expediteur, destinataire, corps)
else:
print fetched_upload_srv
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