mirror of
https://github.com/meshcore-dev/meshcore-cli.git
synced 2026-04-20 22:13:48 +00:00
v1.5.6
This commit is contained in:
parent
2d620f2c33
commit
2bb2dfff02
3 changed files with 22 additions and 34 deletions
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
meshcore = python3Packages.buildPythonPackage rec {
|
||||
pname = "meshcore";
|
||||
version = "2.3.5";
|
||||
version = "2.3.6";
|
||||
pyproject = true;
|
||||
|
||||
src = python3Packages.fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "sha256-EUK0iFaCN2tpOL3XL2ejVLGz/gLTdvzPpvgBxETLL3w=";
|
||||
sha256 = "sha256-l9/wDgRfzPSZGIt+tIUITs/mf/AeEIMDN9DXAbMSzSs=";
|
||||
};
|
||||
|
||||
build-system = [ python3Packages.hatchling ];
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||
|
||||
[project]
|
||||
name = "meshcore-cli"
|
||||
version = "1.5.5"
|
||||
version = "1.5.6"
|
||||
authors = [
|
||||
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
||||
]
|
||||
|
|
@ -17,7 +17,7 @@ classifiers = [
|
|||
]
|
||||
license = "MIT"
|
||||
license-files = ["LICEN[CS]E*"]
|
||||
dependencies = [ "meshcore >= 2.3.5",
|
||||
dependencies = [ "meshcore >= 2.3.6",
|
||||
"bleak >= 0.22",
|
||||
"prompt_toolkit >= 3.0.50",
|
||||
"requests >= 2.28.0" ]
|
||||
|
|
|
|||
|
|
@ -1809,16 +1809,12 @@ async def print_trace_to (mc, contact):
|
|||
|
||||
async def discover_path(mc, contact):
|
||||
await mc.ensure_contacts()
|
||||
res = await mc.commands.send_path_discovery(contact)
|
||||
if res.type == EventType.ERROR:
|
||||
return None
|
||||
else:
|
||||
timeout = res.payload["suggested_timeout"]/600 if not "timeout" in contact or contact['timeout']==0 else contact["timeout"]
|
||||
res = await mc.wait_for_event(EventType.PATH_RESPONSE, timeout=timeout)
|
||||
if res is None:
|
||||
return {"error": "timeout"}
|
||||
else :
|
||||
return res.payload
|
||||
timeout = 0 if not "timeout" in contact else contact["timeout"]
|
||||
res = await mc.commands.send_path_discovery_sync(contact, timeout)
|
||||
if res is None:
|
||||
return {"error": "timeout"}
|
||||
else :
|
||||
return res.payload
|
||||
|
||||
async def print_disc_trace_to (mc, contact):
|
||||
p = await discover_path(mc, contact)
|
||||
|
|
@ -2789,29 +2785,21 @@ async def next_cmd(mc, cmds, json_output=False):
|
|||
sess = PromptSession("Password: ", is_password=True)
|
||||
password = await sess.prompt_async()
|
||||
|
||||
res = await mc.commands.send_login(contact, password)
|
||||
timeout = 0 if not "timeout" in contact else contact["timeout"]
|
||||
res = await mc.commands.send_login_sync(contact, password, timeout = timeout)
|
||||
logger.debug(res)
|
||||
if res.type == EventType.ERROR:
|
||||
if json_output :
|
||||
print(json.dumps({"error" : "Error while login"}))
|
||||
if res is None:
|
||||
print("Login failed : Error or Timeout waiting response")
|
||||
elif json_output :
|
||||
if res.type == EventType.LOGIN_SUCCESS:
|
||||
print(json.dumps({"login_success" : True}, indent=4))
|
||||
else:
|
||||
print(f"Error while loging: {res}")
|
||||
else: # should probably wait for the good ack
|
||||
timeout = res.payload["suggested_timeout"]/800 if not "timeout" in contact or contact['timeout']==0 else contact["timeout"]
|
||||
res = await mc.wait_for_event(EventType.LOGIN_SUCCESS, timeout=timeout)
|
||||
logger.debug(res)
|
||||
if res is None:
|
||||
print("Login failed : Timeout waiting response")
|
||||
elif json_output :
|
||||
if res.type == EventType.LOGIN_SUCCESS:
|
||||
print(json.dumps({"login_success" : True}, indent=4))
|
||||
else:
|
||||
print(json.dumps({"login_success" : False, "error" : "login failed"}, indent=4))
|
||||
print(json.dumps({"login_success" : False, "error" : "login failed"}, indent=4))
|
||||
else:
|
||||
if res.type == EventType.LOGIN_SUCCESS:
|
||||
print("Login success")
|
||||
else:
|
||||
if res.type == EventType.LOGIN_SUCCESS:
|
||||
print("Login success")
|
||||
else:
|
||||
print("Login failed")
|
||||
print("Login failed")
|
||||
|
||||
case "logout" :
|
||||
argnum = 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue