mirror of
https://github.com/HuFlungDu/pylibmeshctrl.git
synced 2026-02-20 13:42:11 +00:00
Compare commits
12 Commits
feat/webso
...
fix/device
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5947e48c5b | ||
|
|
31a8f00cd0 | ||
|
|
871d36b334 | ||
|
|
59fb1f104e | ||
|
|
9bd3e10ed7 | ||
|
|
28e1d94ab9 | ||
|
|
51325a89d3 | ||
|
|
97dff80222 | ||
|
|
8da445348b | ||
|
|
ab1fba5cc1 | ||
|
|
34a80cdda7 | ||
|
|
e226fff8dd |
@@ -2,6 +2,17 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
version 1.2.0
|
||||||
|
=============
|
||||||
|
|
||||||
|
Bugs:
|
||||||
|
* Fixed agent sometimes being None causing an oxception
|
||||||
|
* Fixed bad code in device_open_url
|
||||||
|
|
||||||
|
Features:
|
||||||
|
* Changed websockets version to 15. This now uses the proxy implemention from that library, instead of the previous hack.
|
||||||
|
* Added lastaddr and lastconnect to list_devices API
|
||||||
|
|
||||||
version 1.1.2
|
version 1.1.2
|
||||||
=============
|
=============
|
||||||
Bugs:
|
Bugs:
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class Device(object):
|
|||||||
def __init__(self, nodeid, session, agent=None,
|
def __init__(self, nodeid, session, agent=None,
|
||||||
name=None, desc=None, description=None,
|
name=None, desc=None, description=None,
|
||||||
tags=None, users=None,
|
tags=None, users=None,
|
||||||
agct=None, created_at=None,
|
agct=None, created_at=None,
|
||||||
rname=None, computer_name=None, icon=constants.Icon.desktop,
|
rname=None, computer_name=None, icon=constants.Icon.desktop,
|
||||||
mesh=None, mtype=None, meshtype=None, groupname=None, meshname=None,
|
mesh=None, mtype=None, meshtype=None, groupname=None, meshname=None,
|
||||||
domain=None, host=None, ip=None, conn=None, connected=None,
|
domain=None, host=None, ip=None, conn=None, connected=None,
|
||||||
@@ -71,7 +71,7 @@ class Device(object):
|
|||||||
if links is None:
|
if links is None:
|
||||||
links = {}
|
links = {}
|
||||||
self.links = links
|
self.links = links
|
||||||
if ("ver" in agent):
|
if agent and "ver" in agent:
|
||||||
agent = {
|
agent = {
|
||||||
"version": agent["ver"],
|
"version": agent["ver"],
|
||||||
"id": agent["id"],
|
"id": agent["id"],
|
||||||
|
|||||||
@@ -478,10 +478,25 @@ class Session(object):
|
|||||||
if "result" in res0:
|
if "result" in res0:
|
||||||
raise exceptions.ServerError(res0["result"])
|
raise exceptions.ServerError(res0["result"])
|
||||||
if details:
|
if details:
|
||||||
nodes = json.loads(res0["data"])
|
try:
|
||||||
|
nodes = res0["data"]
|
||||||
|
# Accept any number of nested strings, meshcentral is odd
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
nodes = json.loads(nodes)
|
||||||
|
except TypeError:
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Failed to parse device data: {e}")
|
||||||
|
return
|
||||||
|
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
if node["node"].get("meshid", None):
|
if node["node"].get("meshid", None):
|
||||||
node["node"]["mesh"] = mesh.Mesh(node["node"].get("meshid"), self)
|
node["node"]["mesh"] = mesh.Mesh(node["node"].get("meshid"), self)
|
||||||
|
if "lastConnect" in node and isinstance(node["lastConnect"], dict):
|
||||||
|
node["node"]["lastconnect"] = node["lastConnect"].get("time")
|
||||||
|
node["node"]["lastaddr"] = node["lastConnect"].get("addr")
|
||||||
|
del node["lastConnect"]
|
||||||
details = {}
|
details = {}
|
||||||
for key, val in node.items():
|
for key, val in node.items():
|
||||||
if key != "node":
|
if key != "node":
|
||||||
@@ -1737,10 +1752,11 @@ class Session(object):
|
|||||||
tasks.append(tg.create_task(asyncio.wait_for(_(), timeout=timeout)))
|
tasks.append(tg.create_task(asyncio.wait_for(_(), timeout=timeout)))
|
||||||
tasks.append({ "action": 'msg', "type": 'openUrl', "nodeid": nodeid, "url": url }, "device_open_url", timeout=timeout)
|
tasks.append({ "action": 'msg', "type": 'openUrl', "nodeid": nodeid, "url": url }, "device_open_url", timeout=timeout)
|
||||||
|
|
||||||
|
|
||||||
|
success = tasks[0].result()
|
||||||
res = tasks[1].result()
|
res = tasks[1].result()
|
||||||
success = tasks[2].result()
|
|
||||||
|
|
||||||
if data.get("result", "ok").lower() != "ok":
|
if res.get("result", "ok").lower() != "ok":
|
||||||
raise exceptions.ServerError(data["result"])
|
raise exceptions.ServerError(data["result"])
|
||||||
|
|
||||||
if not success:
|
if not success:
|
||||||
@@ -1964,4 +1980,4 @@ class _FileExplorerWrapper:
|
|||||||
return await self._files.__aenter__()
|
return await self._files.__aenter__()
|
||||||
|
|
||||||
async def __aexit__(self, exc_t, exc_v, exc_tb):
|
async def __aexit__(self, exc_t, exc_v, exc_tb):
|
||||||
return await self._files.__aexit__(exc_t, exc_v, exc_tb)
|
return await self._files.__aexit__(exc_t, exc_v, exc_tb)
|
||||||
|
|||||||
Reference in New Issue
Block a user