Skip to content

Commit 2bb2dff

Browse files
committed
v1.5.6
1 parent 2d620f2 commit 2bb2dff

3 files changed

Lines changed: 22 additions & 34 deletions

File tree

flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
meshcore = python3Packages.buildPythonPackage rec {
1919
pname = "meshcore";
20-
version = "2.3.5";
20+
version = "2.3.6";
2121
pyproject = true;
2222

2323
src = python3Packages.fetchPypi {
2424
inherit pname version;
25-
sha256 = "sha256-EUK0iFaCN2tpOL3XL2ejVLGz/gLTdvzPpvgBxETLL3w=";
25+
sha256 = "sha256-l9/wDgRfzPSZGIt+tIUITs/mf/AeEIMDN9DXAbMSzSs=";
2626
};
2727

2828
build-system = [ python3Packages.hatchling ];

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "meshcore-cli"
7-
version = "1.5.5"
7+
version = "1.5.6"
88
authors = [
99
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
1010
]
@@ -17,7 +17,7 @@ classifiers = [
1717
]
1818
license = "MIT"
1919
license-files = ["LICEN[CS]E*"]
20-
dependencies = [ "meshcore >= 2.3.5",
20+
dependencies = [ "meshcore >= 2.3.6",
2121
"bleak >= 0.22",
2222
"prompt_toolkit >= 3.0.50",
2323
"requests >= 2.28.0" ]

src/meshcore_cli/meshcore_cli.py

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,16 +1809,12 @@ async def print_trace_to (mc, contact):
18091809

18101810
async def discover_path(mc, contact):
18111811
await mc.ensure_contacts()
1812-
res = await mc.commands.send_path_discovery(contact)
1813-
if res.type == EventType.ERROR:
1814-
return None
1815-
else:
1816-
timeout = res.payload["suggested_timeout"]/600 if not "timeout" in contact or contact['timeout']==0 else contact["timeout"]
1817-
res = await mc.wait_for_event(EventType.PATH_RESPONSE, timeout=timeout)
1818-
if res is None:
1819-
return {"error": "timeout"}
1820-
else :
1821-
return res.payload
1812+
timeout = 0 if not "timeout" in contact else contact["timeout"]
1813+
res = await mc.commands.send_path_discovery_sync(contact, timeout)
1814+
if res is None:
1815+
return {"error": "timeout"}
1816+
else :
1817+
return res.payload
18221818

18231819
async def print_disc_trace_to (mc, contact):
18241820
p = await discover_path(mc, contact)
@@ -2789,29 +2785,21 @@ async def next_cmd(mc, cmds, json_output=False):
27892785
sess = PromptSession("Password: ", is_password=True)
27902786
password = await sess.prompt_async()
27912787

2792-
res = await mc.commands.send_login(contact, password)
2788+
timeout = 0 if not "timeout" in contact else contact["timeout"]
2789+
res = await mc.commands.send_login_sync(contact, password, timeout = timeout)
27932790
logger.debug(res)
2794-
if res.type == EventType.ERROR:
2795-
if json_output :
2796-
print(json.dumps({"error" : "Error while login"}))
2791+
if res is None:
2792+
print("Login failed : Error or Timeout waiting response")
2793+
elif json_output :
2794+
if res.type == EventType.LOGIN_SUCCESS:
2795+
print(json.dumps({"login_success" : True}, indent=4))
27972796
else:
2798-
print(f"Error while loging: {res}")
2799-
else: # should probably wait for the good ack
2800-
timeout = res.payload["suggested_timeout"]/800 if not "timeout" in contact or contact['timeout']==0 else contact["timeout"]
2801-
res = await mc.wait_for_event(EventType.LOGIN_SUCCESS, timeout=timeout)
2802-
logger.debug(res)
2803-
if res is None:
2804-
print("Login failed : Timeout waiting response")
2805-
elif json_output :
2806-
if res.type == EventType.LOGIN_SUCCESS:
2807-
print(json.dumps({"login_success" : True}, indent=4))
2808-
else:
2809-
print(json.dumps({"login_success" : False, "error" : "login failed"}, indent=4))
2797+
print(json.dumps({"login_success" : False, "error" : "login failed"}, indent=4))
2798+
else:
2799+
if res.type == EventType.LOGIN_SUCCESS:
2800+
print("Login success")
28102801
else:
2811-
if res.type == EventType.LOGIN_SUCCESS:
2812-
print("Login success")
2813-
else:
2814-
print("Login failed")
2802+
print("Login failed")
28152803

28162804
case "logout" :
28172805
argnum = 1

0 commit comments

Comments
 (0)