From 88504a6191f03ac784d3e7535f92a9ed8f8110f9 Mon Sep 17 00:00:00 2001 From: Hamed Sabri Date: Wed, 9 Sep 2020 16:00:26 -0400 Subject: [PATCH] Fix build script with python 3 where each line starting with 'b and ends with \n' making it hard to read the log. --- build.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.py b/build.py index e98a0c14f3..6afb16748b 100755 --- a/build.py +++ b/build.py @@ -5,6 +5,7 @@ import argparse import contextlib +import codecs import datetime import distutils import multiprocessing @@ -124,7 +125,7 @@ def Run(context, cmd): """Run the specified command in a subprocess.""" PrintInfo('Running "{cmd}"'.format(cmd=cmd)) - with open(context.logFileLocation, "a") as logfile: + with codecs.open(context.logFileLocation, "a", "utf-8") as logfile: logfile.write("#####################################################################################" + "\n") logfile.write("log date: " + datetime.datetime.now().strftime("%Y-%m-%d %H:%M") + "\n") commitID,commitData = GetGitHeadInfo(context) @@ -146,7 +147,7 @@ def Run(context, cmd): if l != "": # Avoid "UnicodeEncodeError: 'ascii' codec can't encode # character" errors by serializing utf8 byte strings. - logfile.write(str(l.encode("utf8"))) + logfile.write(l) PrintCommandOutput(l) elif p.poll() is not None: break