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

add flag to base64 enconding

commit d37f6bd9bd6a932f7ed82e3b9d522848e8fe0fe0
Author: Nicolas KAROLAK <nicolas@karolak.fr>
Date:   Mon Jul 8 09:07:08 2019 +0000

    add flag to base64 enconding
parent 537d2ec2
No related branches found
No related tags found
No related merge requests found
......@@ -140,6 +140,8 @@ TESTER_IGNORED_TESTS=
TESTER_DNS_RESOLUTION_IGNORED=
# ignore these nginx vhosts
TESTER_DNS_RESOLUTION_IGNORED=
# encode report attachment to base64
TESTER_BASE64_ATTACH='0'
# -- Constants --
CYAN='\033[0;36m'
......
......@@ -442,6 +442,7 @@ class Tester:
now.strftime("%Y-%m-%d_%H-%M-%S"),
)
log_content = strip_colors(log_buffer.getvalue())
log_content_encoding = "utf-8"
with open(os.path.join(log_dir, log_name), "w") as fo:
fo.write(log_content)
# Send email
......@@ -511,6 +512,9 @@ class Tester:
)
return 1
boundary = str(uuid.uuid4())
if utils.get_conf("TESTER_BASE64_ATTACH") != "0":
log_content_encoding = "base64"
log_content = base64.b64encode(log_content.encode("utf-8")).decode()
mail = """From: %(hostname)s <%(sender)s>
To: %(recipients)s
Subject: %(system_domain)s (%(hostname)s) %(system_type)s health report: %(status)s
......@@ -527,7 +531,7 @@ 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: base64
Content-transfer-encoding: %(log_content_encoding)s
%(log_content)s""" % dict(
boundary=boundary,
......@@ -538,7 +542,8 @@ Content-transfer-encoding: base64
date=now.strftime("%Y-%m-%d %H:%M:%S"),
report=html_report,
log_name=log_name,
log_content=base64.b64encode(log_content.encode("utf-8")).decode(),
log_content_encoding=log_content_encoding,
log_content=log_content,
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