Fix log streamer for py35
Change-Id: I142eaa04972ae1e09900ada1040eca422b5875b7
diff --git a/zuul/lib/log_streamer.py b/zuul/lib/log_streamer.py
index 9764237..8bb586f 100644
--- a/zuul/lib/log_streamer.py
+++ b/zuul/lib/log_streamer.py
@@ -48,23 +48,26 @@
'''
def handle(self):
- build_uuid = self.request.recv(1024)
+ build_uuid = self.request.recv(1024).decode("utf-8")
build_uuid = build_uuid.rstrip()
# validate build ID
if not re.match("[0-9A-Fa-f]+$", build_uuid):
- self.request.sendall('Build ID %s is not valid' % build_uuid)
+ msg = 'Build ID %s is not valid' % build_uuid
+ self.request.sendall(msg.encode("utf-8"))
return
job_dir = os.path.join(self.server.jobdir_root, build_uuid)
if not os.path.exists(job_dir):
- self.request.sendall('Build ID %s not found' % build_uuid)
+ msg = 'Build ID %s not found' % build_uuid
+ self.request.sendall(msg.encode("utf-8"))
return
# check if log file exists
log_file = os.path.join(job_dir, 'ansible', 'ansible_log.txt')
if not os.path.exists(log_file):
- self.request.sendall('Log not found for build ID %s' % build_uuid)
+ msg = 'Log not found for build ID %s' % build_uuid
+ self.request.sendall(msg.encode("utf-8"))
return
self.stream_log(log_file)
@@ -97,7 +100,7 @@
chunk = log.file.read(4096)
if not chunk:
break
- self.request.send(chunk)
+ self.request.send(chunk.encode('utf-8'))
return log
def follow_log(self, log):
@@ -106,7 +109,7 @@
while True:
chunk = log.file.read(4096)
if chunk:
- self.request.send(chunk)
+ self.request.send(chunk.encode('utf-8'))
else:
break