From a794355f5369555482077d4a60f49343240e7f61 Mon Sep 17 00:00:00 2001 From: Lovi <62809003+Lovi-0@users.noreply.github.com> Date: Sun, 12 Jan 2025 14:18:58 +0100 Subject: [PATCH] Fix "Richiesto con criteri ..." --- Installer/win_install.bat | 64 ++++++++++----------- StreamingCommunity/Util/ffmpeg_installer.py | 18 ++++-- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/Installer/win_install.bat b/Installer/win_install.bat index e5d767d..d160e41 100644 --- a/Installer/win_install.bat +++ b/Installer/win_install.bat @@ -1,13 +1,9 @@ @echo off -:: Spostarsi nella directory superiore rispetto a quella corrente -cd .. - :: Check if the script is running as administrator net session >nul 2>&1 if %errorlevel% neq 0 ( echo Running as administrator... - :: Restart the script with administrator privileges powershell -Command "Start-Process '%~f0' -Verb RunAs" exit /b ) @@ -17,6 +13,15 @@ SETLOCAL ENABLEDELAYEDEXPANSION echo Script starting... +:: Check if PowerShell is available +where powershell >nul 2>&1 +IF %ERRORLEVEL% NEQ 0 ( + echo PowerShell is not available on this system. Please ensure it is installed and configured. + echo Press any key to close... + pause >nul + exit /b 1 +) + :: Check if Chocolatey is already installed :check_choco echo Checking if Chocolatey is installed... @@ -26,16 +31,19 @@ IF %ERRORLEVEL% EQU 0 ( goto install_python ) ELSE ( echo Installing Chocolatey... - @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" || ( + @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" || ( echo Error during Chocolatey installation. + echo Press any key to close... + pause >nul exit /b 1 ) echo Chocolatey installed successfully. - call choco --version - echo. - echo Please restart the terminal to continue... - pause - exit /b + where choco >nul 2>&1 || ( + echo Chocolatey is not recognized. Ensure it is correctly installed and PATH is configured. + echo Press any key to close... + pause >nul + exit /b 1 + ) ) :: Check if Python is already installed @@ -44,45 +52,27 @@ echo Checking if Python is installed... python -V >nul 2>&1 IF %ERRORLEVEL% EQU 0 ( echo Python is already installed. Skipping installation. - goto install_ffmpeg ) ELSE ( echo Installing Python... choco install python --confirm --params="'/NoStore'" --allow-downgrade || ( echo Error during Python installation. + echo Press any key to close... + pause >nul exit /b 1 ) echo Python installed successfully. call python -V echo. echo Please restart the terminal to continue... - pause + pause >nul exit /b ) -:: Check if FFmpeg is already installed -:install_ffmpeg -echo Checking if FFmpeg is installed... -ffmpeg -version >nul 2>&1 -IF %ERRORLEVEL% EQU 0 ( - echo FFmpeg is already installed. Skipping installation. - goto create_venv -) ELSE ( - echo Installing FFmpeg... - choco install ffmpeg --confirm || ( - echo Error during FFmpeg installation. - exit /b 1 - ) - echo FFmpeg installed successfully. - call ffmpeg -version - echo. -) - :: Verify installations :verifica_installazioni echo Verifying installations... call choco --version call python -V -call ffmpeg -version echo All programs have been successfully installed and verified. @@ -95,6 +85,8 @@ if exist .venv ( echo Creating the .venv virtual environment... python -m venv .venv || ( echo Error during virtual environment creation. + echo Press any key to close... + pause >nul exit /b 1 ) echo Virtual environment created successfully. @@ -102,19 +94,27 @@ if exist .venv ( :: Activate the virtual environment and install requirements echo Installing requirements... +echo Current directory: %CD% call .venv\Scripts\activate.bat pip install -r requirements.txt || ( echo Error during requirements installation. + echo Press any key to close... + pause >nul exit /b 1 ) :: Run test_run.py echo Running test_run.py... call .venv\Scripts\python .\test_run.py || ( - echo Error during run.py execution. + echo Error during test_run.py execution. + echo Press any key to close... + pause >nul exit /b 1 ) echo End of script. +echo Press any key to close... +pause >nul + ENDLOCAL \ No newline at end of file diff --git a/StreamingCommunity/Util/ffmpeg_installer.py b/StreamingCommunity/Util/ffmpeg_installer.py index dc27683..6d27354 100644 --- a/StreamingCommunity/Util/ffmpeg_installer.py +++ b/StreamingCommunity/Util/ffmpeg_installer.py @@ -324,14 +324,20 @@ def check_ffmpeg() -> Tuple[Optional[str], Optional[str], Optional[str]]: # Windows detection elif system_platform == 'windows': try: - ffmpeg_path = subprocess.check_output(['where', 'ffmpeg'], text=True).strip().split('\n')[0] - ffprobe_path = subprocess.check_output(['where', 'ffprobe'], text=True).strip().split('\n')[0] - ffplay_path = subprocess.check_output(['where', 'ffplay'], text=True).strip().split('\n')[0] + ffmpeg_path = subprocess.check_output( + ['where', 'ffmpeg'], stderr=subprocess.DEVNULL, text=True + ).strip().split('\n')[0] - if ffmpeg_path and ffprobe_path: - return ffmpeg_path, ffprobe_path, ffplay_path + ffprobe_path = subprocess.check_output( + ['where', 'ffprobe'], stderr=subprocess.DEVNULL, text=True + ).strip().split('\n')[0] + + ffplay_path = subprocess.check_output( + ['where', 'ffplay'], stderr=subprocess.DEVNULL, text=True + ).strip().split('\n')[0] + except subprocess.CalledProcessError: - pass + logging.warning("One or more FFmpeg binaries were not found with command where") # Linux detection else: