diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-02-10 11:14:23 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-02-10 11:14:23 +0100 |
commit | f4368e5e44081d848a9949df567a42b18fe8aa66 (patch) | |
tree | e89a5df19f800a37b2558dddabd741ac69e30e9d /doc | |
parent | 4ee1e821f2ea6d7cd3c30d6cff2e631bc7f89dfd (diff) | |
download | dabmux-f4368e5e44081d848a9949df567a42b18fe8aa66.tar.gz dabmux-f4368e5e44081d848a9949df567a42b18fe8aa66.tar.bz2 dabmux-f4368e5e44081d848a9949df567a42b18fe8aa66.zip |
Improve zmq_remote.py usability and python3 compat
Diffstat (limited to 'doc')
-rwxr-xr-x | doc/zmq_remote.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/doc/zmq_remote.py b/doc/zmq_remote.py index bc9dd5d..155390b 100755 --- a/doc/zmq_remote.py +++ b/doc/zmq_remote.py @@ -22,12 +22,21 @@ message_parts = sys.argv[2:] # first do a ping test -print("ping") -sock.send("ping") +print("Send ping") +sock.send("ping".encode()) data = sock.recv_multipart() -print("Received: {}".format(len(data))) -for i,part in enumerate(data): - print(" {}".format(part)) + +if len(data) != 1: + print("Received invalid number of parts: {}".format(len(data))) + for i,part in enumerate(data): + print(" {}".format(part)) + sys.exit(1) + +if data[0] != b'ok': + print("Received invalid ping response: {}".format(data.decode())) + sys.exit(1) + +print("Ping ok, sending request '{}'...".format(" ".join(message_parts))) for i, part in enumerate(message_parts): if i == len(message_parts) - 1: @@ -35,17 +44,12 @@ for i, part in enumerate(message_parts): else: f = zmq.SNDMORE - print("Send {}({}): '{}'".format(i, f, part)) - - sock.send(part, flags=f) + sock.send(part.encode(), flags=f) data = sock.recv_multipart() -print("Received: {}".format(len(data))) -for i,part in enumerate(data): - print(" RX {}: {}".format(i, part)) - - +print("Received {} entries:".format(len(data))) +print(" " + " ".join([d.decode() for d in data])) # This is free and unencumbered software released into the public domain. # |