Commit 0664b682 authored by Maxime Bombar's avatar Maxime Bombar

[Scripts] Récupère (et adapte rapidement) scripts d'envoi de mail + git-whatsnew.

parent 7a9c5be1
#!/usr/bin/env python
# -*- mode: python; coding: utf-8 -*-
from mail import *
# -*- mode: python; coding: utf-8 -*-
# Source:
# http://stackoverflow.com/questions/18593661/how-do-i-strftime-a-date-object-in-a-different-locale
import locale
import threading
from datetime import datetime
from contextlib import contextmanager
LOCALE_LOCK = threading.Lock()
@contextmanager
def setlocale(name):
with LOCALE_LOCK:
saved = locale.setlocale(locale.LC_ALL)
try:
current_val = locale.setlocale(locale.LC_ALL, name)
except:
current_val = saved
print "Warning: Failed setting locale %r" % name
try:
yield current_val
finally:
locale.setlocale(locale.LC_ALL, saved)
This diff is collapsed.
#!/bin/bash /usr/scripts/python.sh
#!/usr/bin/python
# -*- coding: utf-8 -*-
import subprocess
......
#!/bin/bash /usr/scripts/python.sh
# -*- mode: python; coding: utf-8 -*-
# TODO: Déprécié soon
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""API pour envoyer facilement un mail en python
Author: Vincent Le Gallic <legallic@crans.org>
"""
import sys
if not '/usr/scripts' in sys.path:
sys.path.append('/usr/scripts')
#: Pour fabriquer un mail en MIME
from email.mime.text import MIMEText
#: Pour encoder le mail en utf-8
......@@ -14,7 +16,7 @@ from email import Charset
from email.Utils import formatdate
Charset.add_charset('utf-8', Charset.QP, Charset.QP, 'utf-8')
import gestion.mail as mail_module
import mail as mail_module
def create_mail(emetteur, destinataires, objet, message, cc=[], more_headers={}):
"""Fabrique un mail"""
......@@ -61,7 +63,7 @@ class Message(object):
"""Fabrique le mail"""
return create_mail(self.emetteur, self.destinataires, self.objet,
self.corps, self.cc, self.more_headers)
def send(self):
"""Envoie le mail"""
return actually_sendmail(self.emetteur, self.destinataires, self.mail())
......
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