From 871d36b334d8a7f586d2c25da5a865555a0af537 Mon Sep 17 00:00:00 2001 From: Daan Selen Date: Thu, 12 Jun 2025 16:35:08 +0200 Subject: [PATCH 1/3] Added support for new MeshCentral response type. https://github.com/Ylianst/MeshCentral/commit/2b4ab2b1226061e62616e6cb2421cd3ea84290ae --- src/meshctrl/session.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/meshctrl/session.py b/src/meshctrl/session.py index 52d2a51..46b9568 100644 --- a/src/meshctrl/session.py +++ b/src/meshctrl/session.py @@ -479,6 +479,16 @@ class Session(object): raise exceptions.ServerError(res0["result"]) if details: nodes = json.loads(res0["data"]) + try: + raw_data = res0["data"] + if isinstance(raw_data, str): + nodes = json.loads(raw_data) + else: + nodes = raw_data + except Exception as e: + print(f"Failed to parse device data: {e}") + return + for node in nodes: if node["node"].get("meshid", None): node["node"]["mesh"] = mesh.Mesh(node["node"].get("meshid"), self) @@ -1969,4 +1979,4 @@ class _FileExplorerWrapper: return await self._files.__aenter__() async def __aexit__(self, exc_t, exc_v, exc_tb): - return await self._files.__aexit__(exc_t, exc_v, exc_tb) \ No newline at end of file + return await self._files.__aexit__(exc_t, exc_v, exc_tb) From 31a8f00cd09253a49ac2a5818f69b7350064bb42 Mon Sep 17 00:00:00 2001 From: Daan Selen Date: Thu, 12 Jun 2025 16:58:19 +0200 Subject: [PATCH 2/3] syntax fix --- src/meshctrl/session.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/meshctrl/session.py b/src/meshctrl/session.py index 46b9568..9981935 100644 --- a/src/meshctrl/session.py +++ b/src/meshctrl/session.py @@ -478,7 +478,6 @@ class Session(object): if "result" in res0: raise exceptions.ServerError(res0["result"]) if details: - nodes = json.loads(res0["data"]) try: raw_data = res0["data"] if isinstance(raw_data, str): From 5947e48c5b507bf21846cdac1d88adc924ac059e Mon Sep 17 00:00:00 2001 From: Josiah Baldwin Date: Sat, 14 Jun 2025 12:42:59 -0700 Subject: [PATCH 3/3] modified node parsing to accept ony number of nested strings --- src/meshctrl/session.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/meshctrl/session.py b/src/meshctrl/session.py index 9981935..110f62a 100644 --- a/src/meshctrl/session.py +++ b/src/meshctrl/session.py @@ -479,11 +479,13 @@ class Session(object): raise exceptions.ServerError(res0["result"]) if details: try: - raw_data = res0["data"] - if isinstance(raw_data, str): - nodes = json.loads(raw_data) - else: - nodes = raw_data + 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