From 09215c0ee8c996e50dd1108ca4d5c99c57ae9b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denilson=20S=C3=A1=20Maia?= Date: Fri, 17 Nov 2023 10:21:28 +0100 Subject: [PATCH] Added support for both DolphinTool and dolphin-tool On some systems the tool is named `dolphin-tool` instead of `DolphinTool`. This commit will try to find the available name before running it. --- verifydump/convert.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/verifydump/convert.py b/verifydump/convert.py index 5befbe8..ac20e67 100644 --- a/verifydump/convert.py +++ b/verifydump/convert.py @@ -1,7 +1,9 @@ +import functools import logging import os import pathlib import re +import shutil import subprocess import tempfile @@ -176,10 +178,24 @@ def convert_gdi_to_cue(gdi_file_path: pathlib.Path, cue_file_path: pathlib.Path) cue_file.write(" INDEX 01 00:02:00\n") +@functools.cache +def find_binary(*names): + for name in names: + fullpath = shutil.which(name) + if fullpath: + return fullpath + + def get_sha1hex_for_rvz(rvz_path, show_command_output: bool) -> str: with tempfile.TemporaryDirectory() as dolphin_tool_user_folder_name: dolphintool_result = subprocess.run( - ["DolphinTool", "verify", "-u", dolphin_tool_user_folder_name, "-i", str(rvz_path), "--algorithm=sha1"], + [ + find_binary("DolphinTool", "dolphin-tool"), + "verify", + "-u", dolphin_tool_user_folder_name, + "-i", str(rvz_path), + "--algorithm=sha1", + ], capture_output=True, text=True, )