Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: sitescripts/submit_email/bin/send_mass_email.py

Issue 29326140: Isssue 3020 - Add a script to disaptch mass emails (Closed)
Left Patch Set: Created Sept. 8, 2015, 2:58 p.m.
Right Patch Set: Get template in advance Created Sept. 8, 2015, 6:19 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/submit_email/bin/__init__.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details. 13 # GNU General Public License for more details.
14 # 14 #
15 # You should have received a copy of the GNU General Public License 15 # You should have received a copy of the GNU General Public License
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
17 17
18 import sys 18 import sys
19 import argparse 19 import argparse
20 import logging 20 import logging
21 21
22 from sitescripts.utils import sendMail 22 from sitescripts.utils import get_template, sendMail
23 23
24 parser = argparse.ArgumentParser(description='Renders the given email template ' 24 parser = argparse.ArgumentParser(description='Renders the given email template '
25 'and dispatches emails to the ' 25 'and dispatches emails to the '
26 'addresses given on stdin') 26 'addresses given on stdin')
27 parser.add_argument('template') 27 parser.add_argument('template')
28 parser.add_argument('--log-level', default='INFO') 28 parser.add_argument('--log-level', default='INFO')
29 29
30 if __name__ == '__main__': 30 if __name__ == '__main__':
31 args = parser.parse_args() 31 args = parser.parse_args()
32 logging.basicConfig(level=args.log_level) 32 logging.basicConfig(level=args.log_level)
33 template = get_template(args.template, False)
33 34
34 for recipient in sys.stdin: 35 for recipient in sys.stdin:
35 recipient = recipient.strip() 36 recipient = recipient.strip()
36 try: 37 try:
37 sendMail(args.template, {'recipient': recipient}) 38 sendMail(template, {'recipient': recipient})
38 except Exception: 39 except Exception:
39 logging.error('Failed to send email to %r', recipient, exc_info=True) 40 logging.error('Failed to send email to %r', recipient, exc_info=True)
40 else: 41 else:
41 logging.info('Sent email to %r', recipient) 42 logging.info('Sent email to %r', recipient)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld