From 6050ddee92dd649740b9c70903be0781214d8342 Mon Sep 17 00:00:00 2001 From: Kazuhiko Shiozaki <kazuhiko@nexedi.com> Date: Mon, 24 Aug 2009 08:04:27 +0000 Subject: [PATCH] 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 --- product/ERP5Type/tests/runFunctionalTest.py | 11 +++++++++-- product/ERP5Type/tests/sendMail.py | 7 ++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/product/ERP5Type/tests/runFunctionalTest.py b/product/ERP5Type/tests/runFunctionalTest.py index 4fba6dad9e..28f0287f24 100755 --- a/product/ERP5Type/tests/runFunctionalTest.py +++ b/product/ERP5Type/tests/runFunctionalTest.py @@ -20,6 +20,7 @@ Options: -h, --help this help screen --email_to_address=STRING send results to this address by email (defaults to erp5-report@erp5.org) + --smtp_host=hostname specify SMTP server -s, --stdout print the results on stdout instead of sending results by email (unless email_to_address is also passed explictly) @@ -45,6 +46,7 @@ send_mail = 0 stdout = 0 debug = 0 email_to_address = 'erp5-report@erp5.org' +smtp_host = '' run_only='' tests_framework_home = os.path.dirname(os.path.abspath(__file__)) @@ -75,6 +77,7 @@ def parseArgs(): global stdout global debug global email_to_address + global smtp_host global host global port global portal_name @@ -83,7 +86,8 @@ def parseArgs(): try: opts, args = getopt.getopt(sys.argv[1:], "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: usage(sys.stderr, msg) sys.exit(2) @@ -96,6 +100,8 @@ def parseArgs(): elif opt == '--email_to_address': email_to_address = arg send_mail = 1 + elif opt == '--smtp_host': + smtp_host = arg elif opt in ('-h', '--help'): usage(sys.stdout) sys.exit() @@ -287,7 +293,8 @@ Following tests failed: status=status, attachments=[detail], from_mail='nobody@svn.erp5.org', - to_mail=[email_to_address]) + to_mail=[email_to_address], + smtp_host=smtp_host) if stdout: print '-' * 79 print subject diff --git a/product/ERP5Type/tests/sendMail.py b/product/ERP5Type/tests/sendMail.py index a7567e68a7..9ff704c16f 100644 --- a/product/ERP5Type/tests/sendMail.py +++ b/product/ERP5Type/tests/sendMail.py @@ -40,7 +40,8 @@ def sendMail(subject, attachments = [], status = False, from_mail = 'nobody@erp5.org', - to_mail = [ 'erp5-report@erp5.org' ]): + to_mail = [ 'erp5-report@erp5.org' ], + smtp_host = ''): if attachments: msg = MIMEMultipart() else: @@ -78,8 +79,8 @@ def sendMail(subject, else: msg.set_payload(body) - # Send the email via our own SMTP server. - s = smtplib.SMTP() + # Send the email via SMTP server. + s = smtplib.SMTP(smtp_host) s.connect() s.sendmail(from_mail, to_mail, msg.as_string()) s.close() -- 2.30.9