From 13f32a8fbfce01abfbb75b294f79aeb900f70235 Mon Sep 17 00:00:00 2001 From: Aydin <108932477+Aydinhamedi@users.noreply.github.com> Date: Thu, 25 Jan 2024 15:24:22 +0330 Subject: [PATCH 1/6] modified: Interface/CLI/CLI.cmd modified: .gitignore --- Interface/CLI/CLI.cmd | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Interface/CLI/CLI.cmd b/Interface/CLI/CLI.cmd index b50c50a..c30f852 100644 --- a/Interface/CLI/CLI.cmd +++ b/Interface/CLI/CLI.cmd @@ -1,5 +1,6 @@ @echo off REM Conf: +setlocal enabledelayedexpansion TITLE Pneumonia-Detection-Ai-CLI set python_min_VER=10 set DEBUG=0 @@ -7,6 +8,8 @@ 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 @@ -17,7 +20,7 @@ if "%arg%"=="-f" ( REM Check if Python is installed "%python_path%" --version 2>nul >nul -if errorlevel 1 goto :errorNoPython +if errorlevel 0 goto :errorNoPython :errorNoPython_C @REM Geting the Python path and Python install time @@ -121,6 +124,26 @@ 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... + timeout /t 5 >nul + start "" "%~f0" + exit + ) ) pause goto :EOF From ef7f1a9f1d8da34f7be348ac7a8d32d0d3cd3f14 Mon Sep 17 00:00:00 2001 From: Aydin <108932477+Aydinhamedi@users.noreply.github.com> Date: Thu, 25 Jan 2024 15:24:30 +0330 Subject: [PATCH 2/6] modified: .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 94a89593ae181fb3258154ef5789f9505e3b3e06 Mon Sep 17 00:00:00 2001 From: Aydin <108932477+Aydinhamedi@users.noreply.github.com> Date: Thu, 25 Jan 2024 15:25:31 +0330 Subject: [PATCH 3/6] modified: Interface/CLI/CLI.cmd --- Interface/CLI/CLI.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Interface/CLI/CLI.cmd b/Interface/CLI/CLI.cmd index c30f852..efb8f7c 100644 --- a/Interface/CLI/CLI.cmd +++ b/Interface/CLI/CLI.cmd @@ -129,7 +129,7 @@ if /I "%UserInput%"=="y" ( REM Download the file using curl echo Downloading the embedded Python... - curl -l -o %Python_Embed_Name% %Python_Embed_URL% + curl -L -o %Python_Embed_Name% %Python_Embed_URL% REM Extract the file to the Data folder echo Extracting the embedded Python... From 16b0d7c83e650961511478c8ed2ba550804d2502 Mon Sep 17 00:00:00 2001 From: Aydin <108932477+Aydinhamedi@users.noreply.github.com> Date: Thu, 25 Jan 2024 15:42:09 +0330 Subject: [PATCH 4/6] modified: Interface/CLI/CLI.cmd deleted: Interface/CLI/Run_CLI.py --- Interface/CLI/CLI.cmd | 5 +++-- Interface/CLI/Run_CLI.py | 33 --------------------------------- 2 files changed, 3 insertions(+), 35 deletions(-) delete mode 100644 Interface/CLI/Run_CLI.py diff --git a/Interface/CLI/CLI.cmd b/Interface/CLI/CLI.cmd index efb8f7c..629b8d5 100644 --- a/Interface/CLI/CLI.cmd +++ b/Interface/CLI/CLI.cmd @@ -112,7 +112,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" ( @@ -140,7 +140,8 @@ if /I "%UserInput%"=="y" ( del "%Python_Embed_Name%" REM Restarting the CLI luncher... - timeout /t 5 >nul + echo Restarting the CLI luncher (in 8 seconds)... + timeout /t 8 >nul start "" "%~f0" exit ) 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 From 621e5f21eb073bc1ccd963b114d6818fdb8059bc Mon Sep 17 00:00:00 2001 From: Aydin <108932477+Aydinhamedi@users.noreply.github.com> Date: Thu, 25 Jan 2024 16:10:24 +0330 Subject: [PATCH 5/6] modified: Interface/CLI/CLI.cmd --- Interface/CLI/CLI.cmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Interface/CLI/CLI.cmd b/Interface/CLI/CLI.cmd index 629b8d5..411d96e 100644 --- a/Interface/CLI/CLI.cmd +++ b/Interface/CLI/CLI.cmd @@ -20,7 +20,7 @@ if "%arg%"=="-f" ( REM Check if Python is installed "%python_path%" --version 2>nul >nul -if errorlevel 0 goto :errorNoPython +if errorlevel 1 goto :errorNoPython :errorNoPython_C @REM Geting the Python path and Python install time @@ -140,7 +140,7 @@ if /I "!UserInput!"=="y" ( del "%Python_Embed_Name%" REM Restarting the CLI luncher... - echo Restarting the CLI luncher (in 8 seconds)... + echo Restarting the CLI luncher (in 8 seconds^^^)... timeout /t 8 >nul start "" "%~f0" exit From a9a255c8496794d8749f5587a2e915ceff40e9b0 Mon Sep 17 00:00:00 2001 From: Aydin <108932477+Aydinhamedi@users.noreply.github.com> Date: Thu, 25 Jan 2024 16:22:13 +0330 Subject: [PATCH 6/6] modified: Interface/CLI/CLI.cmd --- Interface/CLI/CLI.cmd | 1 - 1 file changed, 1 deletion(-) diff --git a/Interface/CLI/CLI.cmd b/Interface/CLI/CLI.cmd index 411d96e..5923e07 100644 --- a/Interface/CLI/CLI.cmd +++ b/Interface/CLI/CLI.cmd @@ -5,7 +5,6 @@ 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"