From 958db0be5be98f3d5ff339482616dd5afef58804 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Wed, 5 Dec 2018 11:09:07 +0800 Subject: [PATCH] Fix UnicodeEncodeError when calling deploy logs Call .encode('utf-8') after splitting string as f.write() is expecting an encoded string to write properly. Issue: RELENG-1515 Change-Id: I88f70af17222fc7931a07e78eba23d9cc60eb9e7 Signed-off-by: Thanh Ha --- lftools/deploy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lftools/deploy.py b/lftools/deploy.py index baeb8505..27b8fe7e 100644 --- a/lftools/deploy.py +++ b/lftools/deploy.py @@ -299,11 +299,11 @@ def deploy_logs(nexus_url, nexus_path, build_url): resp = requests.get('{}/consoleText'.format(_format_url(build_url))) with open('console.log', 'w+') as f: - f.write(resp.text.split(MAGIC_STRING)[0]) + f.write(str(resp.text.split(MAGIC_STRING)[0].encode('utf-8'))) resp = requests.get('{}/timestamps?time=HH:mm:ss&appendLog'.format(_format_url(build_url))) with open('console-timestamp.log', 'w+') as f: - f.write(resp.text.split(MAGIC_STRING)[0]) + f.write(str(resp.text.split(MAGIC_STRING)[0].encode('utf-8'))) _compress_text(work_dir) -- 2.16.6