Fix "Richiesto con criteri ..."

This commit is contained in:
Lovi 2025-01-12 14:18:58 +01:00
parent b88eac4499
commit a794355f53
2 changed files with 44 additions and 38 deletions

View File

@ -1,13 +1,9 @@
@echo off @echo off
:: Spostarsi nella directory superiore rispetto a quella corrente
cd ..
:: Check if the script is running as administrator :: Check if the script is running as administrator
net session >nul 2>&1 net session >nul 2>&1
if %errorlevel% neq 0 ( if %errorlevel% neq 0 (
echo Running as administrator... echo Running as administrator...
:: Restart the script with administrator privileges
powershell -Command "Start-Process '%~f0' -Verb RunAs" powershell -Command "Start-Process '%~f0' -Verb RunAs"
exit /b exit /b
) )
@ -17,6 +13,15 @@ SETLOCAL ENABLEDELAYEDEXPANSION
echo Script starting... 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 if Chocolatey is already installed
:check_choco :check_choco
echo Checking if Chocolatey is installed... echo Checking if Chocolatey is installed...
@ -26,16 +31,19 @@ IF %ERRORLEVEL% EQU 0 (
goto install_python goto install_python
) ELSE ( ) ELSE (
echo Installing Chocolatey... 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 Error during Chocolatey installation.
echo Press any key to close...
pause >nul
exit /b 1 exit /b 1
) )
echo Chocolatey installed successfully. echo Chocolatey installed successfully.
call choco --version where choco >nul 2>&1 || (
echo. echo Chocolatey is not recognized. Ensure it is correctly installed and PATH is configured.
echo Please restart the terminal to continue... echo Press any key to close...
pause pause >nul
exit /b exit /b 1
)
) )
:: Check if Python is already installed :: Check if Python is already installed
@ -44,45 +52,27 @@ echo Checking if Python is installed...
python -V >nul 2>&1 python -V >nul 2>&1
IF %ERRORLEVEL% EQU 0 ( IF %ERRORLEVEL% EQU 0 (
echo Python is already installed. Skipping installation. echo Python is already installed. Skipping installation.
goto install_ffmpeg
) ELSE ( ) ELSE (
echo Installing Python... echo Installing Python...
choco install python --confirm --params="'/NoStore'" --allow-downgrade || ( choco install python --confirm --params="'/NoStore'" --allow-downgrade || (
echo Error during Python installation. echo Error during Python installation.
echo Press any key to close...
pause >nul
exit /b 1 exit /b 1
) )
echo Python installed successfully. echo Python installed successfully.
call python -V call python -V
echo. echo.
echo Please restart the terminal to continue... echo Please restart the terminal to continue...
pause pause >nul
exit /b 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 :: Verify installations
:verifica_installazioni :verifica_installazioni
echo Verifying installations... echo Verifying installations...
call choco --version call choco --version
call python -V call python -V
call ffmpeg -version
echo All programs have been successfully installed and verified. echo All programs have been successfully installed and verified.
@ -95,6 +85,8 @@ if exist .venv (
echo Creating the .venv virtual environment... echo Creating the .venv virtual environment...
python -m venv .venv || ( python -m venv .venv || (
echo Error during virtual environment creation. echo Error during virtual environment creation.
echo Press any key to close...
pause >nul
exit /b 1 exit /b 1
) )
echo Virtual environment created successfully. echo Virtual environment created successfully.
@ -102,19 +94,27 @@ if exist .venv (
:: Activate the virtual environment and install requirements :: Activate the virtual environment and install requirements
echo Installing requirements... echo Installing requirements...
echo Current directory: %CD%
call .venv\Scripts\activate.bat call .venv\Scripts\activate.bat
pip install -r requirements.txt || ( pip install -r requirements.txt || (
echo Error during requirements installation. echo Error during requirements installation.
echo Press any key to close...
pause >nul
exit /b 1 exit /b 1
) )
:: Run test_run.py :: Run test_run.py
echo Running test_run.py... echo Running test_run.py...
call .venv\Scripts\python .\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 exit /b 1
) )
echo End of script. echo End of script.
echo Press any key to close...
pause >nul
ENDLOCAL ENDLOCAL

View File

@ -324,14 +324,20 @@ def check_ffmpeg() -> Tuple[Optional[str], Optional[str], Optional[str]]:
# Windows detection # Windows detection
elif system_platform == 'windows': elif system_platform == 'windows':
try: try:
ffmpeg_path = subprocess.check_output(['where', 'ffmpeg'], text=True).strip().split('\n')[0] ffmpeg_path = subprocess.check_output(
ffprobe_path = subprocess.check_output(['where', 'ffprobe'], text=True).strip().split('\n')[0] ['where', 'ffmpeg'], stderr=subprocess.DEVNULL, text=True
ffplay_path = subprocess.check_output(['where', 'ffplay'], text=True).strip().split('\n')[0] ).strip().split('\n')[0]
if ffmpeg_path and ffprobe_path: ffprobe_path = subprocess.check_output(
return ffmpeg_path, ffprobe_path, ffplay_path ['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: except subprocess.CalledProcessError:
pass logging.warning("One or more FFmpeg binaries were not found with command where")
# Linux detection # Linux detection
else: else: