Initialize connection to the VSI Video Server and start the server process if not already running. Args: address: Tuple (IP, port) for the server. authkey: Authorization key for server connection. Returns: None
(address, authkey)
| 244 | |
| 245 | |
| 246 | def init(address, authkey): |
| 247 | """ |
| 248 | Initialize connection to the VSI Video Server and start the server process if not already running. |
| 249 | Args: |
| 250 | address: Tuple (IP, port) for the server. |
| 251 | authkey: Authorization key for server connection. |
| 252 | Returns: |
| 253 | None |
| 254 | """ |
| 255 | |
| 256 | base_dir = path.dirname(__file__) |
| 257 | server_path = path.join(base_dir, 'vsi_video_server.py') |
| 258 | |
| 259 | logger.info("Start video server") |
| 260 | if path.isfile(server_path): |
| 261 | # Start Video Server as a subprocess |
| 262 | if os_name == 'nt': |
| 263 | py_cmd = 'python' |
| 264 | else: |
| 265 | py_cmd = 'python3' |
| 266 | cmd = f"{py_cmd} {server_path} "\ |
| 267 | f"--ip {address[0]} "\ |
| 268 | f"--port {address[1]} "\ |
| 269 | f"--authkey {authkey}" |
| 270 | subprocess.Popen(cmd, shell=True) |
| 271 | |
| 272 | # Connect to Video Server |
| 273 | Video.connectToServer(address, authkey) |
| 274 | if Video.conn == None: |
| 275 | logger.error("Server not connected") |
| 276 | else: |
| 277 | logger.error(f"Server script not found: {server_path}") |
| 278 | |
| 279 | # Register clean-up function |
| 280 | atexit.register(cleanup) |
| 281 | |
| 282 | if Video.conn == None: |
| 283 | return False |
| 284 | else: |
| 285 | return True |
| 286 | |
| 287 | |
| 288 | def timerEvent(): |
nothing calls this directly
no test coverage detected