From 80875944b75c59e6f405a68633a7140f72f84e3f Mon Sep 17 00:00:00 2001 From: Stefano Maffulli Date: Wed, 23 Oct 2013 15:44:33 -0700 Subject: [PATCH] Adds the script used to send summit invitations to ATC Change-Id: If67bdf6099067e96dc168027db6e8f5ee7e4b4cb Closes-Bug: #1243930 --- .gitignore | 2 + tools/invite2summit/README | 15 +++++ tools/invite2summit/atc_sample.csv | 3 + tools/invite2summit/codes_sample.csv | 3 + tools/invite2summit/sample.atc.csv | 3 + tools/invite2summit/send.py | 77 ++++++++++++++++++++++++++ tools/invite2summit/settings.py.sample | 53 ++++++++++++++++++ 7 files changed, 156 insertions(+) create mode 100644 tools/invite2summit/README create mode 100644 tools/invite2summit/atc_sample.csv create mode 100644 tools/invite2summit/codes_sample.csv create mode 100644 tools/invite2summit/sample.atc.csv create mode 100644 tools/invite2summit/send.py create mode 100644 tools/invite2summit/settings.py.sample diff --git a/.gitignore b/.gitignore index eb9aba1f3b..58341e91bc 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ manifests/secrets.pp openstack_infra_config.egg-info/ /.project /.pydevproject +tools/invite2summit/settings.py +tools/invite2summit/done* diff --git a/tools/invite2summit/README b/tools/invite2summit/README new file mode 100644 index 0000000000..4d92ced701 --- /dev/null +++ b/tools/invite2summit/README @@ -0,0 +1,15 @@ +It sends codes from codes.csv to ATCs in atc.csv and outputs a csv file +with which name corresponds to which code. + +You use it like this: + +- Copy settings.py.sample to settings.py +- Update values in settings.py, especially EMAIL_USER, EMAIL_FROM, +EMAIL_SIGNATURE and EMAIL_PASSWORD +- Run a test with "python send.py atc_sample.csv codes_sample.csv" + +Should work on stock Ubuntu. + +When ready, run the real thing with: + +$ python send.py atc.csv codes.csv > sent.csv diff --git a/tools/invite2summit/atc_sample.csv b/tools/invite2summit/atc_sample.csv new file mode 100644 index 0000000000..bd34bd6c1b --- /dev/null +++ b/tools/invite2summit/atc_sample.csv @@ -0,0 +1,3 @@ +stef,Stefano Maffulli,stefano@openstack.org +mark,Mark Collier,mark@openstack.org +lauren,Lauren Sell,lauren@openstack.org diff --git a/tools/invite2summit/codes_sample.csv b/tools/invite2summit/codes_sample.csv new file mode 100644 index 0000000000..94d8d3c8b6 --- /dev/null +++ b/tools/invite2summit/codes_sample.csv @@ -0,0 +1,3 @@ +LILCFRL,, +TEST,, +TESTING,, diff --git a/tools/invite2summit/sample.atc.csv b/tools/invite2summit/sample.atc.csv new file mode 100644 index 0000000000..e30a3cafaa --- /dev/null +++ b/tools/invite2summit/sample.atc.csv @@ -0,0 +1,3 @@ +reed, Stefano Maffulli,stefano@openstack.org,stefano@maffulli.net +sparky,Mark Collier,sparkycollier@gmail.com,mark@openstack.org +claire,Claire Massey,claire@openstack.org diff --git a/tools/invite2summit/send.py b/tools/invite2summit/send.py new file mode 100644 index 0000000000..0e30159291 --- /dev/null +++ b/tools/invite2summit/send.py @@ -0,0 +1,77 @@ +# Summit passcode-sending application +# +# Copyright 2013 Thierry Carrez +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import csv +import settings +import smtplib +import sys +import time +from string import Template + + +class ATC(object): + def __init__(self, row): + self.lpid = row[0] + self.name = row[1] + self.emails = row[2:] + + +if __name__ == '__main__': + + if len(sys.argv) != 3: + print "Usage: %s atc.csv codes.csv" % sys.argv[0] + sys.exit(1) + + atcfile = sys.argv[1] + codesfile = sys.argv[2] + + committers = [] + with open(atcfile, 'r') as f: + reader = csv.reader(f) + for row in reader: + committers.append(ATC(row)) + + codes = [] + with open(codesfile, 'r') as f: + reader = csv.reader(f) + for row in reader: + codes.append(row[0]) + + for committer, code in zip(committers, codes): + if settings.EMAIL_USE_SSL: + session = smtplib.SMTP_SSL(settings.EMAIL_HOST, settings.EMAIL_PORT) + else: + session = smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT) + if settings.EMAIL_USE_TLS: + session.starttls() + session.login(settings.EMAIL_USER, settings.EMAIL_PASSWORD) + session.set_debuglevel(settings.EMAIL_DEBUGLEVEL) + + template = Template(settings.EMAIL_TEMPLATE) + content = template.substitute(name=committer.name, + code=code, + signature=settings.EMAIL_SIGNATURE) + msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s" % ( + settings.EMAIL_FROM, + ','.join(committer.emails), + settings.EMAIL_SUBJECT, + content) + + session.sendmail(settings.EMAIL_FROM, committer.emails, msg) + print "%s,ATC,%s" % (code, committer.name) + session.quit() + time.sleep(settings.EMAIL_PAUSE) diff --git a/tools/invite2summit/settings.py.sample b/tools/invite2summit/settings.py.sample new file mode 100644 index 0000000000..ae5c8a4a14 --- /dev/null +++ b/tools/invite2summit/settings.py.sample @@ -0,0 +1,53 @@ +# Settings for the passcode-sending application +# +# Copyright 2013 Thierry Carrez +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +EMAIL_SUBJECT = "Your registration code for OpenStack Summit in Portland" + +EMAIL_TEMPLATE = """ +Hello $name, + +As you may already know, we'll be having our next OpenStack Summit +in Portland from April 15 to April 18, 2013. We issue free passes to +recent contributors to encourage them to join the OpenStack Summit +and participate to shaping the next release at the Design Summit. + +You've been identified as a contributor in the Folsom and/or Grizzly +development cycles and therefore have been granted a personal code +for free registration to the whole event. Please use the following +code: + +$code + +The registration site should open sometimes next week. Feel free to +email me with any question you may have. + +Regards, + +-- +$signature +""" + +EMAIL_FROM = "thierry@openstack.org" +EMAIL_SIGNATURE = "Thierry Carrez\nOpenStack Foundation" +EMAIL_HOST = "secure.emailsrvr.com" +EMAIL_PORT = 465 +EMAIL_USER = "thierry.carrez@openstack.org" +EMAIL_PASSWORD = "MYPASSWORDHERE" +EMAIL_USE_SSL = True +EMAIL_USE_TLS = False +EMAIL_DEBUGLEVEL = 0 +EMAIL_PAUSE = 2