re_similar, re_struct_audit; next_functions favours raw functions with a readable near-duplicate
This commit is contained in:
1 parent
2d2f5fe7c5
commit
07a031109b
4 files changed
+65
-4
No files matched your search
@@ -509,3 +509,25 @@ def match_functions(config, targets, decomp=None, flags=None):
|
||||
errors = [line for line in result.stdout.splitlines() if "compile errors" in line]
|
||||
return {"results": rows, "summary": result.stdout.strip().splitlines()[0] if result.stdout.strip() else "",
|
||||
**({"compile": errors[0]} if errors else {})}
|
||||
|
||||
|
||||
def run_toolkit(config, key, argv, json_to_file=False, timeout=900):
|
||||
"""Run the toolkit script configured as [reverse] <key> with argv and return its JSON (stdout, or a temp file
|
||||
passed as `--json <file>` when json_to_file)."""
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
script = (config or {}).get(key)
|
||||
if not script or not Path(script).exists():
|
||||
raise HarborError(f"this project has no {key} script in its [reverse] table")
|
||||
with tempfile.TemporaryDirectory(dir=(config or {}).get("debugger_temp")) as tmp:
|
||||
out = Path(tmp) / "out.json"
|
||||
command = [sys.executable, "-B", str(script), *argv] + (["--json", str(out)] if json_to_file else ["--json"])
|
||||
result = subprocess.run(command, capture_output=True, text=True, encoding="utf-8", errors="replace",
|
||||
timeout=timeout, cwd=str(Path(script).parent),
|
||||
creationflags=getattr(subprocess, "CREATE_NO_WINDOW", 0))
|
||||
text = out.read_text(encoding="utf-8") if json_to_file and out.exists() else result.stdout
|
||||
try:
|
||||
return json.loads(text)
|
||||
except ValueError:
|
||||
raise HarborError(f"{key} failed: " + (result.stdout + result.stderr).strip()[-800:]) from None
|
||||
Reference in new issue
Block a user