diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2008-06-28 03:05:43 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2008-06-28 03:05:43 (GMT) |
commit | f98a8d2931bef72b46ee9a92208877930d3a2663 (patch) | |
tree | 6835778a8025dfe06804973054886a1e7ae71d3a /scripts | |
parent | c54d1b403e7fba5406920005bcfaabe5d4827927 (diff) |
Add ability to send reports by email.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/report.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/scripts/report.py b/scripts/report.py index f18aef7..9a25a27 100644 --- a/scripts/report.py +++ b/scripts/report.py @@ -3,6 +3,9 @@ import sys import urllib import csv import json +import smtplib +from optparse import make_option +import StringIO from jhbuild.commands import Command, register_command @@ -101,6 +104,13 @@ class cmd_report(Command): name = 'report' usage_args = '' + def __init__(self): + Command.__init__(self, [ + make_option('-s', '--sendto', action='append', + dest='sendto', default=None, + help='send report to the specified mail address') + ]) + def run(self, config, options, args): report = None @@ -109,7 +119,24 @@ class cmd_report(Command): report.generate() if report: - report.write(TextWriter(sys.stdout)) + out = StringIO.StringIO() + report.write(TextWriter(out)) + text = out.getvalue() + out.close() + + if options.sendto: + if text: + print 'Sending to ' + ', '.join(options.sendto) + + server = smtplib.SMTP('localhost') + from_address = 'release-team@sugarlabs.org' + + for to_address in options.sendto: + server.sendmail(from_address, to_address, text) + + server.quit() + else: + print 'Empty report, do not send' report.save() |