From 5321ffd2277a277a3aafda23a5956c8c06b4d94f Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 7 Jun 2019 12:46:38 -0700 Subject: [PATCH] Tools: Attempt to make perf.py work with Py3 --- tools/perf.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf.py b/tools/perf.py index 67453ddeb..b6fa04bcb 100755 --- a/tools/perf.py +++ b/tools/perf.py @@ -96,12 +96,15 @@ class PerfServer(object): 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 @@ class PerfServer(object): 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)