showing progress when fetching contacts/channels

This commit is contained in:
Florent de Lamotte 2025-10-22 10:29:59 +02:00
parent 7cf903280b
commit 4b94702c35
2 changed files with 12 additions and 6 deletions

View file

@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "meshcore-cli"
version = "1.1.31"
version = "1.1.32"
authors = [
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
]
@ -17,7 +17,7 @@ classifiers = [
]
license = "MIT"
license-files = ["LICEN[CS]E*"]
dependencies = [ "meshcore >= 2.1.12", "prompt_toolkit >= 3.0.50", "requests >= 2.28.0" ]
dependencies = [ "meshcore >= 2.1.13", "prompt_toolkit >= 3.0.50", "requests >= 2.28.0" ]
[project.urls]
Homepage = "https://github.com/fdlamotte/meshcore-cli"

View file

@ -23,7 +23,7 @@ from prompt_toolkit.shortcuts import radiolist_dialog
from meshcore import MeshCore, EventType, logger
# Version
VERSION = "v1.1.31"
VERSION = "v1.1.32"
# default ble address is stored in a config file
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@ -563,8 +563,8 @@ Line starting with \"$\" or \".\" will issue a meshcli command.
contact = to
prev_contact = None
await mc.ensure_contacts()
await get_channels(mc)
await mc.commands.get_contacts(anim=True)
await get_channels(mc, anim=True)
await subscribe_to_msgs(mc, above=True)
handle_new_contact.print_new_contacts = True
@ -978,10 +978,13 @@ async def get_channel_by_name (mc, name):
return None
async def get_channels (mc) :
async def get_channels (mc, anim=False) :
if hasattr(mc, 'channels') :
return mc.channels
if anim:
print("Fetching channels ", end="", flush=True)
ch = 0;
mc.channels = []
while True:
@ -992,6 +995,9 @@ async def get_channels (mc) :
info["channel_secret"] = info["channel_secret"].hex()
mc.channels.append(info)
ch = ch + 1
if anim:
print(".", end="", flush=True)
print (" Done")
return mc.channels
async def next_cmd(mc, cmds, json_output=False):