From b9162fc097eef1ef9174dc09f29f7ee1058f3da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Sun, 5 Nov 2006 09:24:52 +0000 Subject: [PATCH] Added a "X-ERP5-Tests: ERP5" header for filtering Runs in $INSTANCE_HOME by default git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11095 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/tests/sendMailToList | 38 ++++++++++++++------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/product/ERP5Type/tests/sendMailToList b/product/ERP5Type/tests/sendMailToList index 7b59f33866..388c512183 100755 --- a/product/ERP5Type/tests/sendMailToList +++ b/product/ERP5Type/tests/sendMailToList @@ -1,29 +1,26 @@ #!/usr/bin/python +"""Parses the output of tests from test_output and test_full_output and sends +an email to a list. +Edit this script to change the recipients. +""" + import smtplib import re +import os from datetime import date from email.MIMEText import MIMEText from email.MIMEBase import MIMEBase - -# Here are the email pacakge modules we'll need from email.MIMEImage import MIMEImage from email.MIMEMultipart import MIMEMultipart +# configure this part if needed +from_mail = 'nobody@erp5.org' +to_mail = [ 'erp5-report@erp5.org' ] +INSTANCE_HOME = os.environ.get('INSTANCE_HOME', '/var/lib/zope') -COMMASPACE = ', ' -USER = 'seb' -ZOPE_INSTANCE = '/home/%s/zope' % USER - -subject = 'ERP5 Unit Test' -from_mail = 'seb@nexedi.com' -to_mail = [ 'erp5-report@nexedi.com' - # , 'seb@nexedi.com' - , - ] - - -test_msg = file("%s/Products/test_output" % (ZOPE_INSTANCE),'r').read() +test_msg = file( + os.path.join(INSTANCE_HOME, "Products", "test_output"), 'r').read() test_msg = "Date : %s\n\n" % date.today().isoformat() + test_msg # minimal parsing @@ -53,13 +50,17 @@ subject = "ERP5 r%s: %s Tests, %s Errors, %s Failures" % ( msg = MIMEMultipart() msg['Subject'] = subject msg['From'] = from_mail -msg['To'] = COMMASPACE.join(to_mail) +msg['To'] = ', '.join(to_mail) +# Add custom headers for client side filtering +msg['X-ERP5-Tests'] = 'ERP5' +if not (failures + errors): + msg['X-ERP5-Tests-Status'] = 'OK' # Guarantees the message ends in a newline msg.preamble = subject msg.epilogue = '' -file_content = file("%s/Products/test_full_output" % - (ZOPE_INSTANCE),'r').read() +file_content = file( + os.path.join(INSTANCE_HOME, "Products", "test_full_output"), 'r').read() mime_text = MIMEText(test_msg) mime_text.add_header('Content-Disposition', 'attachment', @@ -75,3 +76,4 @@ s = smtplib.SMTP() s.connect() s.sendmail(from_mail, to_mail, msg.as_string()) s.close() + -- 2.30.9