# 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 from tscut.exceptions import MissingToolError logger = logging.getLogger(__name__) @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 """ 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