|
15 | 15 | import sys |
16 | 16 | import time |
17 | 17 | from pathlib import Path |
| 18 | +from typing import Any, cast |
18 | 19 |
|
19 | 20 | # Add protocol_pb2 to path |
20 | 21 | build_dir = Path(__file__).parent.parent.parent / "build" |
|
25 | 26 | sys.path.insert(0, str(build_dir)) |
26 | 27 |
|
27 | 28 | try: |
28 | | - from protocol_pb2 import Request, Response, Value, ValueType |
| 29 | + import protocol_pb2 as _protocol |
29 | 30 | except ImportError: |
30 | 31 | print("ERROR: protocol_pb2.py not found in build directory") |
31 | 32 | print("Solution: Rebuild with: .\\scripts\\build.ps1 -Release") |
32 | 33 | sys.exit(1) |
33 | 34 |
|
| 35 | +protocol = cast(Any, _protocol) |
| 36 | +Request = protocol.Request |
| 37 | +Response = protocol.Response |
| 38 | +Value = protocol.Value |
| 39 | +ValueType = protocol.ValueType |
| 40 | + |
34 | 41 |
|
35 | 42 | def find_fluxgraph_server(): |
36 | 43 | """Find FluxGraph server executable""" |
@@ -110,7 +117,10 @@ def run_sim_example(): |
110 | 117 |
|
111 | 118 | # Check if provider is still running |
112 | 119 | if provider.poll() is not None: |
113 | | - stderr_output = provider.stderr.read().decode() |
| 120 | + stderr_pipe = provider.stderr |
| 121 | + stderr_output = ( |
| 122 | + stderr_pipe.read().decode() if stderr_pipe is not None else "" |
| 123 | + ) |
114 | 124 | print("[FAIL] Provider terminated unexpectedly:") |
115 | 125 | print(stderr_output) |
116 | 126 | return False |
@@ -198,7 +208,8 @@ def run_sim_example(): |
198 | 208 | finally: |
199 | 209 | # Cleanup |
200 | 210 | try: |
201 | | - provider.stdin.close() |
| 211 | + if provider.stdin is not None: |
| 212 | + provider.stdin.close() |
202 | 213 | provider.terminate() |
203 | 214 | provider.wait(timeout=2) |
204 | 215 | except Exception: |
|
0 commit comments