From 8a85900a16a0cb561a098ea35a34d2904fb99af7 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 18 Aug 2017 16:00:33 +0200 Subject: DPDCE: Make python3 compatible --- dpd/src/Adapt.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'dpd/src/Adapt.py') diff --git a/dpd/src/Adapt.py b/dpd/src/Adapt.py index fec6aa5..2658240 100644 --- a/dpd/src/Adapt.py +++ b/dpd/src/Adapt.py @@ -38,12 +38,12 @@ class Adapt: sock.connect("tcp://%s:%d" % (self.host, self.port)) sock.send(b"ping") - data = sock.recv_multipart() + data = [el.decode() for el in sock.recv_multipart()] if data != ['ok']: raise RuntimeError( - "Could not connect to server %s %d." % - (self.host, self.port)) + "Could not ping server at %s %d: %s" % + (self.host, self.port, data)) return sock @@ -70,7 +70,7 @@ class Adapt: sock.send(part.encode(), flags=f) - data = sock.recv_multipart() + data = [el.decode() for el in sock.recv_multipart()] logging.info("Received message: %s" % message) return data @@ -132,9 +132,9 @@ class Adapt: def _write_coef_file(self, coefs_complex): f = open(self.coef_path, 'w') - f.write("{}\n".format(len(coefs_complex)).encode()) + f.write("{}\n".format(len(coefs_complex))) for coef in coefs_complex: - f.write("{}\n{}\n".format(coef.real, coef.imag).encode()) + f.write("{}\n{}\n".format(coef.real, coef.imag)) f.close() def set_coefs(self, coefs_complex): -- cgit v1.2.3