mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-17 00:25:23 +03:00
Handle invalid intel json
This commit is contained in:
parent
2713928f7b
commit
ad86d5e2b4
@ -279,10 +279,27 @@ def get_intel_gpu_stats() -> dict[str, str]:
|
|||||||
logger.error(f"Unable to poll intel GPU stats: {p.stderr}")
|
logger.error(f"Unable to poll intel GPU stats: {p.stderr}")
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
|
output = "".join(p.stdout.split())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = json.loads(f'[{"".join(p.stdout.split())}]')
|
data = json.loads(f"[{output}]")
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
return {"gpu": "-%", "mem": "-%"}
|
data = None
|
||||||
|
|
||||||
|
# json is incomplete, remove characters until we get to valid json
|
||||||
|
while True:
|
||||||
|
while output and output[-1] != "}":
|
||||||
|
output = output[:-1]
|
||||||
|
|
||||||
|
if not output:
|
||||||
|
return {"gpu": "", "mem": ""}
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = json.loads(f"[{output}]")
|
||||||
|
break
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
output = output[:-1]
|
||||||
|
continue
|
||||||
|
|
||||||
results: dict[str, str] = {}
|
results: dict[str, str] = {}
|
||||||
render = {"global": []}
|
render = {"global": []}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user