From 24c9ae55b5528a076472c25c43abb76498c59f8e Mon Sep 17 00:00:00 2001 From: SG Date: Mon, 15 May 2023 10:31:07 +0200 Subject: [PATCH] Print file name during transfer --- transmat/transmat.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/transmat/transmat.py b/transmat/transmat.py index 391832e..bfaf4c0 100755 --- a/transmat/transmat.py +++ b/transmat/transmat.py @@ -147,7 +147,7 @@ async def main(): message = json.loads(message) if message["msgtype"] == "announce" and message["peer_group_id"] == peer_group_id: break - bar = Bar('Transferring', max=number_of_chunks, check_tty=False, suffix='%(percent).1f%% complete - %(eta_td)s remaining') + bar = Bar(filename, max=number_of_chunks, check_tty=False, suffix='%(percent).1f%% complete - %(eta_td)s remaining') msgtype = "data" async for chunk in read_chunks(file_path, chunk_size): msg = (msgtype, peer_group_id, role, filename, chunk_size, chunk_id, number_of_chunks, chunk) @@ -174,10 +174,11 @@ async def main(): msg = pickle.loads(decrypt_chunk(k, payload)) chunk_id = msg["chunk_id"] number_of_chunks = msg["number_of_chunks"] + filename = msg["filename"] if bar is None: - bar = Bar('Receiving', max=number_of_chunks, check_tty=False, suffix='%(percent).1f%% complete - %(eta_td)s remaining') + bar = Bar(filename, max=number_of_chunks, check_tty=False, suffix='%(percent).1f%% complete - %(eta_td)s remaining') if f is None: - f = open(msg["filename"], "wb") + f = open(filename, "wb") f.write(msg["chunk"]) else: f.write(msg["chunk"])