twister: set encoding during open log file
Set the same encoding for collected CMake output and file where this output will be saved. Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
This commit is contained in:
parent
951654cf18
commit
b029bfd65c
1 changed files with 8 additions and 6 deletions
|
@ -2277,6 +2277,8 @@ class CMake():
|
|||
self.generator = None
|
||||
self.generator_cmd = None
|
||||
|
||||
self.default_encoding = sys.getdefaultencoding()
|
||||
|
||||
def parse_generated(self):
|
||||
self.defconfig = {}
|
||||
return {}
|
||||
|
@ -2310,8 +2312,8 @@ class CMake():
|
|||
results = {'msg': msg, "returncode": p.returncode, "instance": self.instance}
|
||||
|
||||
if out:
|
||||
log_msg = out.decode(sys.getdefaultencoding())
|
||||
with open(os.path.join(self.build_dir, self.log), "a") as log:
|
||||
log_msg = out.decode(self.default_encoding)
|
||||
with open(os.path.join(self.build_dir, self.log), "a", encoding=self.default_encoding) as log:
|
||||
log.write(log_msg)
|
||||
|
||||
else:
|
||||
|
@ -2320,8 +2322,8 @@ class CMake():
|
|||
# A real error occurred, raise an exception
|
||||
log_msg = ""
|
||||
if out:
|
||||
log_msg = out.decode(sys.getdefaultencoding())
|
||||
with open(os.path.join(self.build_dir, self.log), "a") as log:
|
||||
log_msg = out.decode(self.default_encoding)
|
||||
with open(os.path.join(self.build_dir, self.log), "a", encoding=self.default_encoding) as log:
|
||||
log.write(log_msg)
|
||||
|
||||
if log_msg:
|
||||
|
@ -2401,8 +2403,8 @@ class CMake():
|
|||
results = {"returncode": p.returncode}
|
||||
|
||||
if out:
|
||||
with open(os.path.join(self.build_dir, self.log), "a") as log:
|
||||
log_msg = out.decode(sys.getdefaultencoding())
|
||||
with open(os.path.join(self.build_dir, self.log), "a", encoding=self.default_encoding) as log:
|
||||
log_msg = out.decode(self.default_encoding)
|
||||
log.write(log_msg)
|
||||
|
||||
return results
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue