From c7880e2c8ddade47ba11a3095279cbdf641b58c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 25 Aug 2018 20:34:43 +0200 Subject: [PATCH] Donate CPU: Made client python3 compatible --- tools/donate-cpu.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py index e824511c5..117d1aa4f 100644 --- a/tools/donate-cpu.py +++ b/tools/donate-cpu.py @@ -76,11 +76,11 @@ def getPackage(): server_address = ('cppcheck.osuosl.org', 8000) sock.connect(server_address) try: - sock.sendall('get\n') + sock.send(b'get\n') package = sock.recv(256) finally: sock.close() - return package + return package.decode('utf-8') def wget(url, destfile): @@ -120,7 +120,7 @@ def scanPackage(workPath, cppcheck): print(cmd) p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) comm = p.communicate() - errout = comm[1] + errout = comm[1].decode('utf-8') count = 0 for line in errout.split('\n'): if re.match(r'.*:[0-9]+:[0-9]+: [a-z]+: .*\]$', line): @@ -133,12 +133,13 @@ def scanPackage(workPath, cppcheck): def sendAll(connection, data): - while data: - bytes = connection.send(data) - if bytes < len(data): - data = data[bytes:] + bytes = data.encode() + while bytes: + num = connection.send(bytes) + if num < len(bytes): + bytes = bytes[num:] else: - data = None + bytes = None def uploadResults(package, results):