fix: spawn login/open child with python -m for PyArmor runtime path
All checks were successful
技能自动化发布 / release (push) Successful in 31s
All checks were successful
技能自动化发布 / release (push) Successful in 31s
This commit is contained in:
@@ -21,6 +21,9 @@ from util.platforms import (
|
||||
|
||||
# 子进程入口脚本与本模块同目录(独立解释器执行,非 import)
|
||||
_SERVICE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
# PyArmor 在模块首行注入对 pyarmor_runtime_* 的 import;若以「脚本路径」启动子进程,
|
||||
# sys.path[0] 仅为 service/,找不到 scripts/ 下的运行时包。必须用 -m 且 cwd=scripts/(标准做法)。
|
||||
_SCRIPTS_ROOT = os.path.dirname(_SERVICE_DIR)
|
||||
|
||||
|
||||
def _win_find_exe(candidates):
|
||||
@@ -196,7 +199,6 @@ def _run_login_browser_session(
|
||||
url,
|
||||
log_file,
|
||||
)
|
||||
login_runner_path = os.path.join(_SERVICE_DIR, "login_child_runner.py")
|
||||
cfg = {
|
||||
"channel": channel,
|
||||
"profile_dir": profile_dir,
|
||||
@@ -223,7 +225,8 @@ def _run_login_browser_session(
|
||||
child_stdout = ""
|
||||
try:
|
||||
r = subprocess.run(
|
||||
[sys.executable, login_runner_path, cfg_path],
|
||||
[sys.executable, "-m", "service.login_child_runner", cfg_path],
|
||||
cwd=_SCRIPTS_ROOT,
|
||||
timeout=timeout_sec + 180,
|
||||
env=subprocess_env_with_trace(),
|
||||
capture_output=True,
|
||||
@@ -481,7 +484,6 @@ def cmd_open(account_id):
|
||||
print("请在本窗口中自行确认登录态。关闭浏览器后命令结束。")
|
||||
print("需要自动检测登录时,请执行:python main.py login <id>")
|
||||
|
||||
open_runner_path = os.path.join(_SERVICE_DIR, "open_child_runner.py")
|
||||
cfg = {"channel": channel, "profile_dir": profile_dir, "url": url}
|
||||
with tempfile.NamedTemporaryFile(
|
||||
mode="w", suffix=".json", delete=False, encoding="utf-8"
|
||||
@@ -490,7 +492,8 @@ def cmd_open(account_id):
|
||||
cfg_path = jf.name
|
||||
try:
|
||||
subprocess.run(
|
||||
[sys.executable, open_runner_path, cfg_path],
|
||||
[sys.executable, "-m", "service.open_child_runner", cfg_path],
|
||||
cwd=_SCRIPTS_ROOT,
|
||||
env=subprocess_env_with_trace(),
|
||||
)
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user