d
This commit is contained in:
@@ -1534,19 +1534,11 @@ def main(argv: Optional[list[str]] = None) -> int:
|
||||
client_found = p
|
||||
break
|
||||
|
||||
script_dir = Path(__file__).resolve().parent
|
||||
ensure_run_client_helper(dest, script_dir)
|
||||
|
||||
run_client_script = None
|
||||
if client_found:
|
||||
script_dir = Path(__file__).resolve().parent
|
||||
helper_src = script_dir / "run_client.py"
|
||||
helper_dest = dest / "run_client.py"
|
||||
if helper_src.exists() and not helper_dest.exists():
|
||||
try:
|
||||
shutil.copy2(helper_src, helper_dest)
|
||||
if os.name != "nt":
|
||||
helper_dest.chmod(helper_dest.stat().st_mode | 0o111)
|
||||
logging.debug("Copied run_client helper to %s", helper_dest)
|
||||
except Exception as exc: # pragma: no cover - best effort
|
||||
logging.debug("Failed to copy run_client helper: %s", exc)
|
||||
# Prefer run_client helper located in the cloned repo; if missing, fall back to top-level scripts folder helper.
|
||||
helper_candidates = [dest / "run_client.py", script_dir / "run_client.py"]
|
||||
for cand in helper_candidates:
|
||||
@@ -1784,5 +1776,30 @@ def main(argv: Optional[list[str]] = None) -> int:
|
||||
return 99
|
||||
|
||||
|
||||
def ensure_run_client_helper(dest: Path, script_dir: Path) -> Optional[Path]:
|
||||
"""Ensure the run_client helper is installed inside the target repository."""
|
||||
helper_src = script_dir / "run_client.py"
|
||||
if not helper_src.exists():
|
||||
logging.debug(
|
||||
"run_client helper not found in %s; skipping copy.",
|
||||
helper_src,
|
||||
)
|
||||
return None
|
||||
|
||||
helper_dest = dest / "run_client.py"
|
||||
if helper_dest.exists():
|
||||
return helper_dest
|
||||
|
||||
try:
|
||||
shutil.copy2(helper_src, helper_dest)
|
||||
if os.name != "nt":
|
||||
helper_dest.chmod(helper_dest.stat().st_mode | 0o111)
|
||||
logging.debug("Copied run_client helper to %s", helper_dest)
|
||||
return helper_dest
|
||||
except Exception as exc:
|
||||
logging.debug("Failed to copy run_client helper: %s", exc)
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
|
||||
Reference in New Issue
Block a user