|
8 | 8 |
|
9 | 9 | import atexit |
10 | 10 | import os |
| 11 | +import pathlib |
11 | 12 | import socket |
12 | 13 |
|
13 | 14 | # The subprocess module is needed to start the backend. |
@@ -139,22 +140,23 @@ def start_application(grpc_host:str="localhost", \ |
139 | 140 | ld_env = os.getenv('LD_LIBRARY_PATH') |
140 | 141 | if ld_env: |
141 | 142 | for path in ld_env.split(':'): |
142 | | - if os.path.exists(os.path.join(path, "stkruntime")): |
143 | | - cmd_line = [os.path.join(path, "stkruntime"), "--grpcHost", grpc_host, "--grpcPort", str(grpc_port)] |
| 143 | + stkruntime_path = (pathlib.Path(path) / "stkruntime").resolve() |
| 144 | + if stkruntime_path.exists(): |
| 145 | + cmd_line = [stkruntime_path, "--grpcHost", grpc_host, "--grpcPort", str(grpc_port)] |
144 | 146 | if no_graphics: |
145 | 147 | cmd_line.append("--noGraphics") |
146 | 148 | break |
147 | 149 | else: |
148 | 150 | raise STKInitializationError("LD_LIBRARY_PATH not defined. Add STK bin directory to LD_LIBRARY_PATH before running.") |
149 | 151 | else: |
150 | 152 | clsid_stkxapplication = "{062AB565-B121-45B5-A9A9-B412CEFAB6A9}" |
151 | | - stkx_dll_path = read_registry_key(f"CLSID\\{clsid_stkxapplication}\\InprocServer32", silent_exception=True) |
152 | | - bin_dir, dll_name = (None, None) if stkx_dll_path is None else os.path.split(stkx_dll_path) |
153 | | - if bin_dir is None or not os.path.exists(os.path.join(bin_dir, "STKRuntime.exe")): |
154 | | - bin_dir = winreg_stk_binary_dir() |
155 | | - if bin_dir is None: |
| 153 | + stkx_dll_registry_value = read_registry_key(f"CLSID\\{clsid_stkxapplication}\\InprocServer32", silent_exception=True) |
| 154 | + stkruntime_path = None if stkx_dll_registry_value is None else pathlib.Path(stkx_dll_registry_value).parent / "STKRuntime.exe" |
| 155 | + if stkruntime_path is None or not stkruntime_path.exists(): |
| 156 | + stkruntime_path = pathlib.Path(winreg_stk_binary_dir()) / "STKRuntime.exe" |
| 157 | + if not stkruntime_path.exists(): |
156 | 158 | raise STKInitializationError(f"Could not find STKRuntime.exe. Verify STK installation.") |
157 | | - cmd_line = [os.path.join(bin_dir, "STKRuntime.exe"), "/grpcHost", grpc_host, "/grpcPort", str(grpc_port)] |
| 159 | + cmd_line = [str(stkruntime_path.resolve()), "/grpcHost", grpc_host, "/grpcPort", str(grpc_port)] |
158 | 160 | if no_graphics: |
159 | 161 | cmd_line.append("/noGraphics") |
160 | 162 |
|
|
0 commit comments