sync: SHANGHAI-U9 2026-08-19 硬编码审计:imx6_app REPO / fpga_ru --host 改读 skills_env.md(新增 SMOD_REPO_ROOT)
This commit is contained in:
@@ -30,6 +30,25 @@ import socket
|
||||
import sys
|
||||
import time
|
||||
|
||||
def _env_lookup(key, default=None):
|
||||
"""Machine-relative value: real env var first, then ~/skills_env.md."""
|
||||
v = os.environ.get(key)
|
||||
if v:
|
||||
return v
|
||||
path = os.path.join(os.path.expanduser("~"), "skills_env.md")
|
||||
try:
|
||||
with open(path, encoding="utf-8") as f:
|
||||
for line in f:
|
||||
m = re.match(rf"\s*{key}\s*=\s*(\S+)", line)
|
||||
if m:
|
||||
return m.group(1)
|
||||
except OSError:
|
||||
pass
|
||||
if default is None:
|
||||
sys.exit(f"missing {key}: add it to ~/skills_env.md or set it as an env var")
|
||||
return default
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ protocol constants
|
||||
|
||||
HEAD, TAIL = 0xAA, 0xBB
|
||||
@@ -246,7 +265,7 @@ def do_finish(dev, timeout):
|
||||
def main():
|
||||
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
ap.add_argument("--mcs", required=True, help="path to the quickboot <tag>_update.mcs")
|
||||
ap.add_argument("--host", default="192.168.1.143")
|
||||
ap.add_argument("--host", default=_env_lookup("SMOD_BOARD_IP", "192.168.1.143"))
|
||||
ap.add_argument("--port", type=int, default=1234)
|
||||
ap.add_argument("--yes", action="store_true", help="skip the confirmation prompt")
|
||||
ap.add_argument("--dry-run", action="store_true", help="validate and frame the mcs, contact nothing")
|
||||
|
||||
Reference in New Issue
Block a user