Tools: Attempt to make perf.py work with Py3
Vicki Pfau vi@endrift.com
Fri, 07 Jun 2019 12:46:38 -0700
1 files changed,
6 insertions(+),
3 deletions(-)
jump to
M
tools/perf.py
→
tools/perf.py
@@ -96,12 +96,15 @@ server_command.append('-N')
subprocess.check_call(server_command) time.sleep(4) self.socket = socket.create_connection(self.address, timeout=1000) - self.reader = csv.DictReader(self.socket.makefile()) + kwargs = {} + if sys.version_info[0] >= 3: + kwargs["encoding"] = "utf-8" + self.reader = csv.DictReader(self.socket.makefile(**kwargs)) def run(self, test): if not self.socket: self._start(test) - self.socket.send(os.path.join("/perfroms", test.rom)) + self.socket.send(os.path.join("/perfroms", test.rom).encode("utf-8")) self.results.append(next(self.reader)) self.iterations -= 1 if self.iterations == 0:@@ -109,7 +112,7 @@ self.finish()
self.iterations = self.ITERATIONS_PER_INSTANCE def finish(self): - self.socket.send("\n"); + self.socket.send(b"\n"); self.reader = None self.socket.close() time.sleep(5)