diff --git a/.gitignore b/.gitignore index 35fe2b4..1947a8e 100644 --- a/.gitignore +++ b/.gitignore @@ -73,4 +73,5 @@ Samples/* /venv_2 /venv /Interface/CLI/Data/Python Embed 3.10.11 -/Interface/CLI/Data/Use_Python_Embed.tmp \ No newline at end of file +/Interface/CLI/Data/Use_Python_Embed.tmp +/Interface/CLI/Python.Embed.3.10.11.exe \ No newline at end of file diff --git a/Interface/CLI/CLI.cmd b/Interface/CLI/CLI.cmd index b50c50a..5923e07 100644 --- a/Interface/CLI/CLI.cmd +++ b/Interface/CLI/CLI.cmd @@ -1,12 +1,14 @@ @echo off REM Conf: +setlocal enabledelayedexpansion TITLE Pneumonia-Detection-Ai-CLI set python_min_VER=10 set DEBUG=0 set arg=%1 -set quotation=\" set PV_filepath="Data\\Python Ver.tmp" set PUE_filepath="Data\\Use_Python_Embed.tmp" +set Python_Embed_URL="https://github.com/Aydinhamedi/Pneumonia-Detection-Ai/releases/download/Other-Data-V1/Python.Embed.3.10.11.exe" +set Python_Embed_Name="Python.Embed.3.10.11.exe" set python_path=python set pip_path=pip @@ -109,7 +111,7 @@ if exist %PUE_filepath% ( ) echo Error: Python is not installed set /p UserInput="Do you want to use the embedded Python (y/n)? " -if /I "%UserInput%"=="y" ( +if /I "!UserInput!"=="y" ( for /D %%X in ("Data\\Python Embed*") do ( if exist "%%X\python.exe" ( if exist "%%X\\Scripts\\pip.exe" ( @@ -121,6 +123,27 @@ if /I "%UserInput%"=="y" ( ) ) echo Error: Failed to find embedded Python. + set /p downloadPython="Do you want to download the embedded Python (y/n)? " + if /I "!downloadPython!"=="y" ( + REM Download the file using curl + echo Downloading the embedded Python... + + curl -L -o %Python_Embed_Name% %Python_Embed_URL% + + REM Extract the file to the Data folder + echo Extracting the embedded Python... + "%Python_Embed_Name%" -o"%cd%\\Data" -y + + REM Delete the original file + echo Deleting the original file... + del "%Python_Embed_Name%" + + REM Restarting the CLI luncher... + echo Restarting the CLI luncher (in 8 seconds^^^)... + timeout /t 8 >nul + start "" "%~f0" + exit + ) ) pause goto :EOF diff --git a/Interface/CLI/Run_CLI.py b/Interface/CLI/Run_CLI.py deleted file mode 100644 index 7504a3c..0000000 --- a/Interface/CLI/Run_CLI.py +++ /dev/null @@ -1,33 +0,0 @@ -import subprocess -import traceback -import sys -import os -# Other -from Data.Utils.print_color_V1_OLD import print_Color -def run_program(file_path): - while True: - try: - try: - # Run the other Python program using subprocess - subprocess.run(["python", file_path], check=True) - except subprocess.CalledProcessError as ERROR_Py: - print_Color("~*An error occurred: \nERROR: ~*" + str(ERROR_Py), ['yellow', 'red'], advanced_mode=True) - print_Color('~*Do you want to see the detailed error message? ~*[~*Y~*/~*n~*]: ', - ['yellow', 'normal', 'green', 'normal', 'red', 'normal'], - advanced_mode = True, - print_END='') - show_detailed_error = input('') - if show_detailed_error.lower() == 'y': - print_Color('detailed error message:', ['yellow']) - #print_Color('1th ERROR (FILE ERROR) [!MAIN!]:', ['red']) - print_Color('2th ERROR (subprocess.run ERROR):', ['red']) - traceback.print_exc() - choice = input("Do you want to restart the program? (y/n): ") - if choice.lower() != "y": - break - os.system('cls' if os.name == 'nt' else 'clear') - else: - break - except OSError: - break -run_program('Data\CLI_main.py') \ No newline at end of file