Remove function to discover if required tools are installed.

This commit is contained in:
Frédéric Tronel
2026-08-29 13:50:46 +02:00
parent e2936d565f
commit 87e326d976
2 changed files with 51 additions and 39 deletions
+51
View File
@@ -0,0 +1,51 @@
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright (C) 2026 Frédéric Tronel
import logging
from shutil import which
from typeguard import typechecked
class MissingToolError(Exception):
pass
@typechecked
def check_required_tools() -> tuple[bool,dict[str,str]]:
"""
Checks if all required external tools are installed.
This function verifies the presence of required and optional external tools on the system.
It returns a tuple containing a boolean indicating whether all optional tools are installed,
along with a dictionary containing the paths to all tools.
Args:
None
Returns:
tuple[bool, dict[str, str]]:
- bool: True if all optional tools are installed, False otherwise
- dict[str, str]: dictionary containing the paths to all tools
"""
logger = logging.getLogger(__name__)
all_optional_tools = True
paths = {}
required = ['ffmpeg', 'ffprobe', 'mkvmerge', 'mkvinfo']
optional = ['mkvextract', 'vobsubocr','tesseract']
for tool in required:
path = which(tool)
if path is None:
logger.error('Required tool: %s is missing.',tool)
raise MissingToolError(tool)
paths[tool] = path
for tool in optional:
path = which(tool)
if path is None:
logger.info('Optional tool: %s is missing.',tool)
all_optional_tools = False
else:
paths[tool] = path
return all_optional_tools, paths