ModelTranslator: 修注册表 rizomuv 值无后缀致发现失效——拼回真实 exe(审查修复)
This commit is contained in:
@@ -33,8 +33,10 @@ def registry_rizom_path():
|
||||
continue
|
||||
key_path = "SOFTWARE\\Rizom Lab\\RizomUV VS RS 202%d.%d" % (i, j)
|
||||
try:
|
||||
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_path)
|
||||
return winreg.QueryValue(key, "rizomuv.exe")
|
||||
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_path) as key:
|
||||
val = winreg.QueryValue(key, "rizomuv.exe")
|
||||
# 注册表值是不带后缀的安装前缀(官方只取 dirname 用),拼回真实 exe
|
||||
return os.path.join(os.path.dirname(val), "rizomuv.exe")
|
||||
except OSError:
|
||||
continue
|
||||
return None
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import rizom_unwrap as ru
|
||||
@@ -21,11 +22,18 @@ class TestCandidatePaths(unittest.TestCase):
|
||||
|
||||
class TestFindRizomuv(unittest.TestCase):
|
||||
def test_missing_exe_raises(self):
|
||||
with mock.patch.dict(os.environ):
|
||||
os.environ.pop("RIZOMUV_EXE", None)
|
||||
with self.assertRaises(ru.RizomError):
|
||||
ru.find_rizomuv("Z:/no/such/rizomuv.exe", use_registry=False,
|
||||
default="Z:/no/default.exe")
|
||||
|
||||
def test_registry_value_is_real_exe_if_present(self):
|
||||
p = ru.registry_rizom_path()
|
||||
if p is None:
|
||||
self.skipTest("本机无 RizomUV 注册表项")
|
||||
self.assertTrue(os.path.isfile(p), "注册表返回值应是真实 exe:%s" % p)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user