diff --git a/transmat/transmat.py b/transmat/transmat.py index 14cae11..133184e 100755 --- a/transmat/transmat.py +++ b/transmat/transmat.py @@ -169,7 +169,16 @@ async def main(): bar = None f = None i = 1 + number_of_chunks = None while True: + if number_of_chunks is not None and i > number_of_chunks: + bar.index = 100 + bar.suffix = '%(percent).1f%% complete' + bar.update() + f.close() + print("") + break + message = await ws.recv() message = json.loads(message) payload = message["payload"] @@ -184,16 +193,11 @@ async def main(): else: f.write(msg["chunk"]) msgtype = "proceed" + i += 1 # This increment has to happen before we try to send the confirmation message await send_encrypted_msg(ws, k, (msgtype, peer_group_id, role, "", "", "", "", "")) # request the next chunk from sender - i += 1 + bar.suffix = "%(percent).1f%% complete - %(eta_td)s remaining " + str(i) + "/" + str(number_of_chunks) + " msg sent" bar.next() - if i > msg["number_of_chunks"] + 1: - bar.index = 100 - bar.suffix = '%(percent).1f%% complete' - bar.update() - f.close() - print("") - break + asyncio.run(main()) \ No newline at end of file