[Erp5-report] r11095 - /erp5/trunk/products/ERP5Type/tests/sendMailToList

nobody at svn.erp5.org nobody at svn.erp5.org
Sun Nov 5 10:24:53 CET 2006


Author: jerome
Date: Sun Nov  5 10:24:52 2006
New Revision: 11095

URL: http://svn.erp5.org?rev=11095&view=rev
Log:
Added a "X-ERP5-Tests: ERP5" header for filtering
Runs in $INSTANCE_HOME by default


Modified:
    erp5/trunk/products/ERP5Type/tests/sendMailToList

Modified: erp5/trunk/products/ERP5Type/tests/sendMailToList
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/sendMailToList?rev=11095&r1=11094&r2=11095&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/sendMailToList (original)
+++ erp5/trunk/products/ERP5Type/tests/sendMailToList Sun Nov  5 10:24:52 2006
@@ -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 at erp5.org'
+to_mail   = [ 'erp5-report at 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 at nexedi.com'
-to_mail   = [ 'erp5-report at nexedi.com'
-            # , 'seb at 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 @@
 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.connect()
 s.sendmail(from_mail, to_mail, msg.as_string())
 s.close()
+




More information about the Erp5-report mailing list