ModelTranslator: --rizom 显式路径独占生效——无效直接报错不回落默认安装
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
b702685e36
commit
455ab48273
@@ -43,9 +43,14 @@ def registry_rizom_path():
|
||||
|
||||
|
||||
def find_rizomuv(cli_arg=None, use_registry=True, default=DEFAULT_RIZOM):
|
||||
"""返回第一个真实存在的 rizomuv.exe;都不存在抛 RizomError。"""
|
||||
"""返回第一个真实存在的 rizomuv.exe;都不存在抛 RizomError。
|
||||
显式指定 cli_arg 时独占生效:路径无效直接报错,不回落其它候选。"""
|
||||
if cli_arg:
|
||||
if os.path.isfile(cli_arg):
|
||||
return cli_arg
|
||||
raise RizomError("指定的 rizomuv.exe 不存在:%s" % cli_arg)
|
||||
reg = registry_rizom_path() if use_registry else None
|
||||
cands = candidate_paths(cli_arg, os.environ.get("RIZOMUV_EXE"), reg, default)
|
||||
cands = candidate_paths(None, os.environ.get("RIZOMUV_EXE"), reg, default)
|
||||
for p in cands:
|
||||
if os.path.isfile(p):
|
||||
return p
|
||||
|
||||
@@ -29,6 +29,12 @@ class TestFindRizomuv(unittest.TestCase):
|
||||
ru.find_rizomuv("Z:/no/such/rizomuv.exe", use_registry=False,
|
||||
default="Z:/no/default.exe")
|
||||
|
||||
def test_explicit_cli_path_is_exclusive(self):
|
||||
# 显式指定的路径不存在必须直接抛错,不得回落默认安装
|
||||
with self.assertRaises(ru.RizomError) as cm:
|
||||
ru.find_rizomuv("Z:/explicit/bad.exe")
|
||||
self.assertIn("Z:/explicit/bad.exe", str(cm.exception))
|
||||
|
||||
def test_registry_value_is_real_exe_if_present(self):
|
||||
p = ru.registry_rizom_path()
|
||||
if p is None:
|
||||
|
||||
Reference in New Issue
Block a user