Fix UnicodeEncodeError when calling deploy logs 25/13825/1 v0.19.1
authorThanh Ha <thanh.ha@linuxfoundation.org>
Wed, 5 Dec 2018 03:09:07 +0000 (11:09 +0800)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Wed, 5 Dec 2018 03:32:23 +0000 (11:32 +0800)
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 <thanh.ha@linuxfoundation.org>
lftools/deploy.py

index baeb850..27b8fe7 100644 (file)
@@ -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)