[LNT] r331968 - Make content of send emails to be in utf-8.

Martin Liska via llvm-commits llvm-commits at lists.llvm.org
Thu May 10 02:06:08 PDT 2018


Author: marxin
Date: Thu May 10 02:06:08 2018
New Revision: 331968

URL: http://llvm.org/viewvc/llvm-project?rev=331968&view=rev
Log:
Make content of send emails to be in utf-8.

Differential Revision: https://reviews.llvm.org/D46186


Modified:
    lnt/trunk/lnt/lnttool/main.py
    lnt/trunk/lnt/util/NTEmailReport.py

Modified: lnt/trunk/lnt/lnttool/main.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/main.py?rev=331968&r1=331967&r2=331968&view=diff
==============================================================================
--- lnt/trunk/lnt/lnttool/main.py (original)
+++ lnt/trunk/lnt/lnttool/main.py Thu May 10 02:06:08 2018
@@ -269,7 +269,7 @@ def action_send_daily_report(instance_pa
             % (config.zorgURL, database, testsuite)
         subject = "Daily Report: %04d-%02d-%02d" % (
             report.year, report.month, report.day)
-        html_report = report.render(ts_url, only_html_body=False)
+        html_report = report.render(ts_url, only_html_body=False).encode('utf-8')
 
         if subject_prefix is not None:
             subject = "%s %s" % (subject_prefix, subject)
@@ -279,7 +279,7 @@ def action_send_daily_report(instance_pa
         msg['Subject'] = subject
         msg['From'] = from_address
         msg['To'] = address
-        msg.attach(email.mime.text.MIMEText(html_report, "html"))
+        msg.attach(email.mime.text.MIMEText(html_report, 'html', 'utf-8'))
 
         # Send the report.
         if not dry_run:
@@ -354,9 +354,9 @@ def action_send_run_comparison(instance_
 
         env = lnt.server.ui.app.create_jinja_environment()
         text_template = env.get_template('reporting/run_report.txt')
-        text_report = text_template.render(data)
+        text_report = text_template.render(data).encode('utf-8')
         html_template = env.get_template('reporting/run_report.html')
-        html_report = html_template.render(data)
+        html_report = html_template.render(data).encode('utf-8')
 
         subject = data['subject']
         if subject_prefix is not None:
@@ -367,8 +367,8 @@ def action_send_run_comparison(instance_
         msg['Subject'] = subject
         msg['From'] = from_address
         msg['To'] = to_address
-        msg.attach(email.mime.text.MIMEText(text_report, 'plain'))
-        msg.attach(email.mime.text.MIMEText(html_report, 'html'))
+        msg.attach(email.mime.text.MIMEText(text_report, 'plain', 'utf-8'))
+        msg.attach(email.mime.text.MIMEText(html_report, 'html', 'utf-8'))
 
         # Send the report.
         if not dry_run:

Modified: lnt/trunk/lnt/util/NTEmailReport.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/util/NTEmailReport.py?rev=331968&r1=331967&r2=331968&view=diff
==============================================================================
--- lnt/trunk/lnt/util/NTEmailReport.py (original)
+++ lnt/trunk/lnt/util/NTEmailReport.py Thu May 10 02:06:08 2018
@@ -23,7 +23,7 @@ def emailReport(result, session, run, ba
 
     # Generate a plain text message if we have no html report.
     if not html_report:
-        msg = email.mime.text.MIMEText(report)
+        msg = email.mime.text.MIMEText(report.encode('utf-8'), 'plain', 'utf-8')
         msg['Subject'] = subject
         msg['From'] = email_config.from_address
         msg['To'] = to
@@ -36,8 +36,8 @@ def emailReport(result, session, run, ba
         # Attach parts into message container, according to RFC 2046, the last
         # part of a multipart message, in this case the HTML message, is best
         # and preferred.
-        msg.attach(email.mime.text.MIMEText(report, 'plain'))
-        msg.attach(email.mime.text.MIMEText(html_report, 'html'))
+        msg.attach(email.mime.text.MIMEText(report.encode('utf-8'), 'plain', 'utf-8'))
+        msg.attach(email.mime.text.MIMEText(html_report.encode('utf-8'), 'html', 'utf-8'))
 
     s = smtplib.SMTP(email_config.host)
     s.sendmail(email_config.from_address, [to], msg.as_string())




More information about the llvm-commits mailing list