Donate CPU: Made client python3 compatible

This commit is contained in:
Daniel Marjamäki 2018-08-25 20:34:43 +02:00
parent 5da38e33c0
commit c7880e2c8d
1 changed files with 9 additions and 8 deletions

View File

@ -76,11 +76,11 @@ def getPackage():
server_address = ('cppcheck.osuosl.org', 8000) server_address = ('cppcheck.osuosl.org', 8000)
sock.connect(server_address) sock.connect(server_address)
try: try:
sock.sendall('get\n') sock.send(b'get\n')
package = sock.recv(256) package = sock.recv(256)
finally: finally:
sock.close() sock.close()
return package return package.decode('utf-8')
def wget(url, destfile): def wget(url, destfile):
@ -120,7 +120,7 @@ def scanPackage(workPath, cppcheck):
print(cmd) print(cmd)
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
comm = p.communicate() comm = p.communicate()
errout = comm[1] errout = comm[1].decode('utf-8')
count = 0 count = 0
for line in errout.split('\n'): for line in errout.split('\n'):
if re.match(r'.*:[0-9]+:[0-9]+: [a-z]+: .*\]$', line): if re.match(r'.*:[0-9]+:[0-9]+: [a-z]+: .*\]$', line):
@ -133,12 +133,13 @@ def scanPackage(workPath, cppcheck):
def sendAll(connection, data): def sendAll(connection, data):
while data: bytes = data.encode()
bytes = connection.send(data) while bytes:
if bytes < len(data): num = connection.send(bytes)
data = data[bytes:] if num < len(bytes):
bytes = bytes[num:]
else: else:
data = None bytes = None
def uploadResults(package, results): def uploadResults(package, results):