mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-11 11:56:18 +00:00
display correct number of dots when fetching contacts
This commit is contained in:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "meshcore"
|
name = "meshcore"
|
||||||
version = "2.1.14"
|
version = "2.1.15"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
||||||
{ name="Alex Wolden", email="awolden@gmail.com" },
|
{ name="Alex Wolden", email="awolden@gmail.com" },
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class ContactCommands(CommandHandlerBase):
|
|||||||
# wait first event
|
# wait first event
|
||||||
res = await self.send(data)
|
res = await self.send(data)
|
||||||
timeout = 5
|
timeout = 5
|
||||||
|
contact_nb = 0
|
||||||
# Inline wait for events to continue waiting for CONTACTS event
|
# Inline wait for events to continue waiting for CONTACTS event
|
||||||
# while receiving NEXT_CONTACTs (or it might be missed over serial)
|
# while receiving NEXT_CONTACTs (or it might be missed over serial)
|
||||||
try:
|
try:
|
||||||
@@ -26,7 +27,7 @@ class ContactCommands(CommandHandlerBase):
|
|||||||
futures = []
|
futures = []
|
||||||
for event_type in [EventType.ERROR, EventType.NEXT_CONTACT, EventType.CONTACTS] :
|
for event_type in [EventType.ERROR, EventType.NEXT_CONTACT, EventType.CONTACTS] :
|
||||||
future = asyncio.create_task(
|
future = asyncio.create_task(
|
||||||
self.dispatcher.wait_for_event(event_type, {}, timeout)
|
self.dispatcher.wait_for_event(event_type, {}, timeout=timeout)
|
||||||
)
|
)
|
||||||
futures.append(future)
|
futures.append(future)
|
||||||
|
|
||||||
@@ -50,10 +51,14 @@ class ContactCommands(CommandHandlerBase):
|
|||||||
if event:
|
if event:
|
||||||
if event.type == EventType.NEXT_CONTACT:
|
if event.type == EventType.NEXT_CONTACT:
|
||||||
if anim:
|
if anim:
|
||||||
|
contact_nb = contact_nb+1
|
||||||
print(".", end="", flush=True)
|
print(".", end="", flush=True)
|
||||||
else: # Done or Error ... cancel pending and return
|
else: # Done or Error ... cancel pending and return
|
||||||
if anim:
|
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:
|
for future in pending:
|
||||||
future.cancel()
|
future.cancel()
|
||||||
return event
|
return event
|
||||||
|
|||||||
Reference in New Issue
Block a user