(binary_path: str)
| 369 | |
| 370 | |
| 371 | def get_binary_path_versions(binary_path: str) -> dict: |
| 372 | ret = {} |
| 373 | binary_path = os.path.abspath( |
| 374 | replace_binary_path(binary_path) |
| 375 | ) |
| 376 | |
| 377 | for utility in UTILITIES_ARRAY: |
| 378 | ret[utility] = None |
| 379 | full_path = os.path.join(binary_path, |
| 380 | (utility if os.name != 'nt' else |
| 381 | (utility + '.exe'))) |
| 382 | |
| 383 | try: |
| 384 | # if path doesn't exist raise exception |
| 385 | if not os.path.isdir(binary_path): |
| 386 | current_app.logger.warning('Invalid binary path.') |
| 387 | raise FileNotFoundError() |
| 388 | # Get the output of the '--version' command |
| 389 | cmd = subprocess.run( |
| 390 | [full_path, '--version'], |
| 391 | shell=False, |
| 392 | capture_output=True, |
| 393 | text=True |
| 394 | ) |
| 395 | if cmd.returncode == 0: |
| 396 | ret[utility] = cmd.stdout.split(") ", 1)[1].strip() |
| 397 | except Exception as _: |
| 398 | continue |
| 399 | |
| 400 | return ret |
| 401 | |
| 402 | |
| 403 | def set_binary_path(binary_path, bin_paths, server_type, |
no test coverage detected