Commit b9162fc0 authored by Jérome Perrin's avatar Jérome Perrin

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
parent f9391ad7
#!/usr/bin/python #!/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 smtplib
import re import re
import os
from datetime import date from datetime import date
from email.MIMEText import MIMEText from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase from email.MIMEBase import MIMEBase
# Here are the email pacakge modules we'll need
from email.MIMEImage import MIMEImage from email.MIMEImage import MIMEImage
from email.MIMEMultipart import MIMEMultipart 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 = ', ' test_msg = file(
USER = 'seb' os.path.join(INSTANCE_HOME, "Products", "test_output"), 'r').read()
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 = "Date : %s\n\n" % date.today().isoformat() + test_msg test_msg = "Date : %s\n\n" % date.today().isoformat() + test_msg
# minimal parsing # minimal parsing
...@@ -53,13 +50,17 @@ subject = "ERP5 r%s: %s Tests, %s Errors, %s Failures" % ( ...@@ -53,13 +50,17 @@ subject = "ERP5 r%s: %s Tests, %s Errors, %s Failures" % (
msg = MIMEMultipart() msg = MIMEMultipart()
msg['Subject'] = subject msg['Subject'] = subject
msg['From'] = from_mail 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 # Guarantees the message ends in a newline
msg.preamble = subject msg.preamble = subject
msg.epilogue = '' msg.epilogue = ''
file_content = file("%s/Products/test_full_output" % file_content = file(
(ZOPE_INSTANCE),'r').read() os.path.join(INSTANCE_HOME, "Products", "test_full_output"), 'r').read()
mime_text = MIMEText(test_msg) mime_text = MIMEText(test_msg)
mime_text.add_header('Content-Disposition', 'attachment', mime_text.add_header('Content-Disposition', 'attachment',
...@@ -75,3 +76,4 @@ s = smtplib.SMTP() ...@@ -75,3 +76,4 @@ s = smtplib.SMTP()
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