From 7cb47609453bd4e3b5703c4d1189c5d4d3bdb447 Mon Sep 17 00:00:00 2001 From: Florent Date: Thu, 23 Oct 2025 08:24:46 +0200 Subject: [PATCH] display correct number of dots when fetching contacts --- pyproject.toml | 2 +- src/meshcore/commands/contact.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a39b1ae..7db3b96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "meshcore" -version = "2.1.14" +version = "2.1.15" authors = [ { name="Florent de Lamotte", email="florent@frizoncorrea.fr" }, { name="Alex Wolden", email="awolden@gmail.com" }, diff --git a/src/meshcore/commands/contact.py b/src/meshcore/commands/contact.py index 43aa35c..b77be29 100644 --- a/src/meshcore/commands/contact.py +++ b/src/meshcore/commands/contact.py @@ -19,6 +19,7 @@ class ContactCommands(CommandHandlerBase): # wait first event res = await self.send(data) timeout = 5 + contact_nb = 0 # Inline wait for events to continue waiting for CONTACTS event # while receiving NEXT_CONTACTs (or it might be missed over serial) try: @@ -26,7 +27,7 @@ class ContactCommands(CommandHandlerBase): futures = [] for event_type in [EventType.ERROR, EventType.NEXT_CONTACT, EventType.CONTACTS] : future = asyncio.create_task( - self.dispatcher.wait_for_event(event_type, {}, timeout) + self.dispatcher.wait_for_event(event_type, {}, timeout=timeout) ) futures.append(future) @@ -50,10 +51,14 @@ class ContactCommands(CommandHandlerBase): if event: if event.type == EventType.NEXT_CONTACT: if anim: + contact_nb = contact_nb+1 print(".", end="", flush=True) else: # Done or Error ... cancel pending and return if anim: - print(" Done" if event.type == EventType.CONTACTS else " Error") + if event.type == EventType.CONTACTS: + print ((len(event.payload)-contact_nb)*"." + " Done") + else : + print(" Error") for future in pending: future.cancel() return event