From: Thanh Ha Date: Wed, 5 Dec 2018 03:09:07 +0000 (+0800) Subject: Fix UnicodeEncodeError when calling deploy logs X-Git-Tag: v0.19.1^0 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=958db0be5be98f3d5ff339482616dd5afef58804;p=releng%2Flftools.git 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 --- 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)