From 756e420215a6d5903e32967e42d441e0c18dadf3 Mon Sep 17 00:00:00 2001 From: DogancanYr Date: Sun, 19 Nov 2023 01:01:30 +0300 Subject: [PATCH] Simplification for users who do not know coding. Simplification for users who do not know coding. --- .gitignore => Main/.gitignore | 0 LICENSE => Main/LICENSE | 0 README.md => Main/README.md | 0 Main/main.ps1 | 90 +++++++++++++++++++++++ main.py => Main/main.py | 0 requirements.txt => Main/requirements.txt | 0 {services => Main/services}/alive.py | 0 {services => Main/services}/upload.py | 0 {utilities => Main/utilities}/etc.py | 0 {utilities => Main/utilities}/web.py | 0 Setup.bat | 3 + Start.bat | 5 ++ 12 files changed, 98 insertions(+) rename .gitignore => Main/.gitignore (100%) rename LICENSE => Main/LICENSE (100%) rename README.md => Main/README.md (100%) create mode 100644 Main/main.ps1 rename main.py => Main/main.py (100%) rename requirements.txt => Main/requirements.txt (100%) rename {services => Main/services}/alive.py (100%) rename {services => Main/services}/upload.py (100%) rename {utilities => Main/utilities}/etc.py (100%) rename {utilities => Main/utilities}/web.py (100%) create mode 100644 Setup.bat create mode 100644 Start.bat diff --git a/.gitignore b/Main/.gitignore similarity index 100% rename from .gitignore rename to Main/.gitignore diff --git a/LICENSE b/Main/LICENSE similarity index 100% rename from LICENSE rename to Main/LICENSE diff --git a/README.md b/Main/README.md similarity index 100% rename from README.md rename to Main/README.md diff --git a/Main/main.ps1 b/Main/main.ps1 new file mode 100644 index 0000000..d779793 --- /dev/null +++ b/Main/main.ps1 @@ -0,0 +1,90 @@ +# Define the desired Python version +$pythonVersion = "3.10.0" + +# Check if Python 3.10.0 is already installed +$pythonInstalled = "C:\Program Files\Python310" + +if (-not (Test-Path $pythonInstalled)) { + Clear + # Python 3.10.0 is not installed, proceed with installation + Write-Host "Python $pythonVersion is not installed. Installing now..." -ForegroundColor White + + # Define the download URL for Python 3.10.0 + $pythonInstallerUrl = "https://www.python.org/ftp/python/$pythonVersion/python-$pythonVersion-amd64.exe" + + try { + # Download Python installer + Invoke-WebRequest -Uri $pythonInstallerUrl -OutFile "python-$pythonVersion-amd64.exe" + + # Install Python 3.10.0 + Start-Process -Wait -FilePath ".\python-$pythonVersion-amd64.exe" -ArgumentList "/passive", "InstallAllUsers=1", "PrependPath=1" + + # Check if the installation was successful + $pythonInstalled = Get-Command python -ErrorAction SilentlyContinue + if ($pythonInstalled -eq $null) { + throw "Error: Python $pythonVersion installation failed." + } else { + Clear + Write-Host "Python $pythonVersion has been successfully installed." -ForegroundColor Green + } + } catch { + Write-Host "Error: $_" -ForegroundColor Red + Start-Sleep -Seconds 10 + exit 1 + } finally { + # Remove the installation executable + Remove-Item -Path ".\python-$pythonVersion-amd64.exe" -ErrorAction SilentlyContinue + } +} else { + Write-Host "Python $pythonVersion is already installed." -ForegroundColor Green + Sleep -Seconds 1 +} + +# Add Python to the system environment variables (PATH) +$pythonPath = (Get-Command python).Path +if ($env:Path -notlike "C:\Users\$env:USERNAME\AppData\Local\Programs\Python\Python310\") { + try { + $newPath = "C:\Users\$env:USERNAME\AppData\Local\Programs\Python\Python310\" + [Environment]::SetEnvironmentVariable("PATH", $env:PATH + ";$newPath", [System.EnvironmentVariableTarget]::User) + Write-Host "Python path has been added to the system environment variables."-ForegroundColor Green + } catch { + Write-Host "Error adding Python path to the system environment variables" -ForegroundColor Red + Start-Sleep -Seconds 5 + exit 1 + } +} else { + Write-Host "Python path is already in the system environment variables." ???????????? +} + +# Inform the user about the completion of the script +Write-Host "Python 3.10.0 installation and environment setup completed successfully." -ForegroundColor Green +Sleep -Seconds 1 +# Display a message if Python 3.10.0 installation is canceled +if (-not (Test-Path $pythonInstalled)) { + Clear + Write-Host "Python 3.10.0 installation was canceled.(Installation could not run with administrator rights.)" -ForegroundColor Red + Sleep -Seconds 15 + exit 1 +} + + +# Check if Git is installed +if (-not (Get-Command git -ErrorAction SilentlyContinue)) { + # If Git is not installed, install it using winget + Write-Host 'Installing Git using winget...' + winget install Git -e + + # Check if installation was successful + if (Get-Command git -ErrorAction SilentlyContinue) { + Write-Host 'Git has been successfully installed.' -ForegroundColor Green + Start-Sleep -Seconds 5 + } else { + Write-Host 'Failed to install Git. Please check the installation.' -ForegroundColor Red + Start-Sleep -Seconds 10 + } +} else { + Write-Host 'Git is already installed.' -ForegroundColor Green + Start-Sleep -Seconds 5 +} + + diff --git a/main.py b/Main/main.py similarity index 100% rename from main.py rename to Main/main.py diff --git a/requirements.txt b/Main/requirements.txt similarity index 100% rename from requirements.txt rename to Main/requirements.txt diff --git a/services/alive.py b/Main/services/alive.py similarity index 100% rename from services/alive.py rename to Main/services/alive.py diff --git a/services/upload.py b/Main/services/upload.py similarity index 100% rename from services/upload.py rename to Main/services/upload.py diff --git a/utilities/etc.py b/Main/utilities/etc.py similarity index 100% rename from utilities/etc.py rename to Main/utilities/etc.py diff --git a/utilities/web.py b/Main/utilities/web.py similarity index 100% rename from utilities/web.py rename to Main/utilities/web.py diff --git a/Setup.bat b/Setup.bat new file mode 100644 index 0000000..2660897 --- /dev/null +++ b/Setup.bat @@ -0,0 +1,3 @@ +@echo off +cd .\Main +powershell -ExecutionPolicy Bypass -File "main.ps1" diff --git a/Start.bat b/Start.bat new file mode 100644 index 0000000..1b635fc --- /dev/null +++ b/Start.bat @@ -0,0 +1,5 @@ +@echo off +cd .\Main\ +pip install -q -r requirements.txt +cls +Start py -3.10 main.py \ No newline at end of file