display correct number of dots when fetching contacts

This commit is contained in:
Florent 2025-10-23 08:24:46 +02:00
parent caabf6dfd9
commit 7cb4760945
2 changed files with 8 additions and 3 deletions

View file

@ -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" },

View file

@ -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