From 3825943eb6fb117e3602da0f9be0955bde73ec19 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Aug 06 2021 10:31:04 +0000 Subject: [PATCH 1/2] py3 Popen text mode fix --- diff --git a/vm/kojikamid.py b/vm/kojikamid.py index 4460e35..b773465 100755 --- a/vm/kojikamid.py +++ b/vm/kojikamid.py @@ -548,11 +548,11 @@ def run(cmd, chdir=None, fatal=False, log=True): logger = logging.getLogger('koji.vm') logger.info('$ %s', ' '.join(cmd)) proc = subprocess.Popen(cmd, stdout=logfd, stderr=subprocess.STDOUT, - close_fds=True) + close_fds=True, text=True) ret = proc.wait() else: proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - close_fds=True) + close_fds=True, text=True) output, dummy = proc.communicate() ret = proc.returncode if olddir: From d54ace3b4ef5229db405c0d9f3051f15c5ba4895 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Aug 06 2021 10:38:49 +0000 Subject: [PATCH 2/2] use decode for py3 bytes/strings Fixes: https://pagure.io/koji/issue/2976 --- diff --git a/vm/kojikamid.py b/vm/kojikamid.py index b773465..c74671b 100755 --- a/vm/kojikamid.py +++ b/vm/kojikamid.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 # Koji daemon that runs in a Windows VM and executes commands associated # with a task. @@ -32,6 +32,7 @@ import hashlib import logging import os import re +import six # needed for imported code import subprocess import sys import tempfile @@ -607,7 +608,7 @@ def upload_file(server, prefix, path): data = fobj.read(131072) if not data: break - encoded = base64.b64encode(data) + encoded = base64.b64encode(data).decode() server.upload(path, encode_int(offset), encoded) offset += len(data) sum.update(data) @@ -700,7 +701,7 @@ def stream_logs(server, handler, builds): contents = fd.read(65536) if contents: size = len(contents) - data = base64.b64encode(contents) + data = base64.b64encode(contents).decode() digest = hashlib.sha256(contents).hexdigest() del contents try: