Skip to content
Snippets Groups Projects
Commit 2d5af558 authored by Nicolas KAROLAK's avatar Nicolas KAROLAK
Browse files

fix sender and base64 encode attachment

parent b97ab5f7
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
Script to start tests and to manage their results
"""
import base64
from io import StringIO
import datetime
import os
......@@ -324,7 +325,10 @@ class Tester:
log("Test start: %s UTC." % start_date.strftime("%Y-%m-%d %H:%M:%S"))
# Run test
p = subprocess.Popen(
command, stdin=sys.stdin, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
command,
stdin=sys.stdin,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
out, err = p.communicate()
if out:
......@@ -478,6 +482,7 @@ class Tester:
log(consecutive_msg)
html_report += "\n<br/>" + consecutive_msg.replace("\n", "\n<br/>")
if send_email:
sender = utils.get_conf("EMAIL_SENDER", "root@%s" % hostname)
recipients = utils.get_conf("EMAIL_ADMINS") or ""
system_domain = utils.get_conf("MS_SERVER_NAME")
system_type = "MediaServer"
......@@ -506,7 +511,7 @@ class Tester:
)
return 1
boundary = str(uuid.uuid4())
mail = """From: %(hostname)s <support@ubicast.eu>
mail = """From: %(hostname)s <%(sender)s>
To: %(recipients)s
Subject: %(system_domain)s (%(hostname)s) %(system_type)s health report: %(status)s
Mime-Version: 1.0
......@@ -522,17 +527,18 @@ Content-transfer-encoding: utf-8
--%(boundary)s
Content-type: text/plain; name="%(log_name)s"; charset=UTF-8
Content-disposition: attachment; filename="%(log_name)s"
Content-transfer-encoding: utf-8
Content-transfer-encoding: base64
%(log_content)s""" % dict(
boundary=boundary,
sender=sender,
hostname=hostname,
recipients=recipients,
status=("KO (%s tests failed)" % failures) if failures > 0 else "OK",
date=now.strftime("%Y-%m-%d %H:%M:%S"),
report=html_report,
log_name=log_name,
log_content=log_content,
log_content=base64.b64encode(log_content.encode("utf-8")).decode(),
system_domain=system_domain,
system_type=system_type,
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment