Commit 6050ddee authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

support '--smtp_host=host' parameter in runFunctionalTest.py.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28565 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5dd7ed76
...@@ -20,6 +20,7 @@ Options: ...@@ -20,6 +20,7 @@ Options:
-h, --help this help screen -h, --help this help screen
--email_to_address=STRING send results to this address by email (defaults to --email_to_address=STRING send results to this address by email (defaults to
erp5-report@erp5.org) erp5-report@erp5.org)
--smtp_host=hostname specify SMTP server
-s, --stdout print the results on stdout instead of sending -s, --stdout print the results on stdout instead of sending
results by email (unless email_to_address is also results by email (unless email_to_address is also
passed explictly) passed explictly)
...@@ -45,6 +46,7 @@ send_mail = 0 ...@@ -45,6 +46,7 @@ send_mail = 0
stdout = 0 stdout = 0
debug = 0 debug = 0
email_to_address = 'erp5-report@erp5.org' email_to_address = 'erp5-report@erp5.org'
smtp_host = ''
run_only='' run_only=''
tests_framework_home = os.path.dirname(os.path.abspath(__file__)) tests_framework_home = os.path.dirname(os.path.abspath(__file__))
...@@ -75,6 +77,7 @@ def parseArgs(): ...@@ -75,6 +77,7 @@ def parseArgs():
global stdout global stdout
global debug global debug
global email_to_address global email_to_address
global smtp_host
global host global host
global port global port
global portal_name global portal_name
...@@ -83,7 +86,8 @@ def parseArgs(): ...@@ -83,7 +86,8 @@ def parseArgs():
try: try:
opts, args = getopt.getopt(sys.argv[1:], opts, args = getopt.getopt(sys.argv[1:],
"hsd", ["help", "stdout", "debug", "hsd", ["help", "stdout", "debug",
"email_to_address=", "host=", "port=", "portal_name=", "run_only="] ) "email_to_address=", "host=", "port=", "portal_name=", "run_only=",
"smtp_host="] )
except getopt.GetoptError, msg: except getopt.GetoptError, msg:
usage(sys.stderr, msg) usage(sys.stderr, msg)
sys.exit(2) sys.exit(2)
...@@ -96,6 +100,8 @@ def parseArgs(): ...@@ -96,6 +100,8 @@ def parseArgs():
elif opt == '--email_to_address': elif opt == '--email_to_address':
email_to_address = arg email_to_address = arg
send_mail = 1 send_mail = 1
elif opt == '--smtp_host':
smtp_host = arg
elif opt in ('-h', '--help'): elif opt in ('-h', '--help'):
usage(sys.stdout) usage(sys.stdout)
sys.exit() sys.exit()
...@@ -287,7 +293,8 @@ Following tests failed: ...@@ -287,7 +293,8 @@ Following tests failed:
status=status, status=status,
attachments=[detail], attachments=[detail],
from_mail='nobody@svn.erp5.org', from_mail='nobody@svn.erp5.org',
to_mail=[email_to_address]) to_mail=[email_to_address],
smtp_host=smtp_host)
if stdout: if stdout:
print '-' * 79 print '-' * 79
print subject print subject
......
...@@ -40,7 +40,8 @@ def sendMail(subject, ...@@ -40,7 +40,8 @@ def sendMail(subject,
attachments = [], attachments = [],
status = False, status = False,
from_mail = 'nobody@erp5.org', from_mail = 'nobody@erp5.org',
to_mail = [ 'erp5-report@erp5.org' ]): to_mail = [ 'erp5-report@erp5.org' ],
smtp_host = ''):
if attachments: if attachments:
msg = MIMEMultipart() msg = MIMEMultipart()
else: else:
...@@ -78,8 +79,8 @@ def sendMail(subject, ...@@ -78,8 +79,8 @@ def sendMail(subject,
else: else:
msg.set_payload(body) msg.set_payload(body)
# Send the email via our own SMTP server. # Send the email via SMTP server.
s = smtplib.SMTP() s = smtplib.SMTP(smtp_host)
s.connect() s.connect()
s.sendmail(from_mail, to_mail, msg.as_string()) s.sendmail(from_mail, to_mail, msg.as_string())
s.close() s.close()
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