INNER CODE UNIT · Python
_run_json
valqore/valqore · benchmarks/run_benchmark.py:80
def _run_json(cmd: list[str]) -> dict | list | None:
try:
p = subprocess.run(cmd, capture_output=True, text=True, timeout=600)
except Exception:
return None
out = p.stdout.strip()
if not out:
return None
try:
return json.loads(out)
except Exception:
# some tools print a banner before JSON; grab from first brace/bracket
for i, ch in enumerate(out):
if ch in "[{":
try:
return json.loads(out[i:])
except Exception:
return None