Renamed freqtrade UI to freqUI

This commit is contained in:
simwai
2024-05-30 10:08:41 +02:00
parent bad1d83cee
commit 074434e83c
+16 -16
View File
@@ -16,7 +16,7 @@ function Write-Log {
if (-not (Test-Path -Path $LogFilePath)) { if (-not (Test-Path -Path $LogFilePath)) {
New-Item -ItemType File -Path $LogFilePath -Force | Out-Null New-Item -ItemType File -Path $LogFilePath -Force | Out-Null
} }
switch ($Level) { switch ($Level) {
'INFO' { Write-Host $Message -ForegroundColor Green } 'INFO' { Write-Host $Message -ForegroundColor Green }
'WARNING' { Write-Host $Message -ForegroundColor Yellow } 'WARNING' { Write-Host $Message -ForegroundColor Yellow }
@@ -34,19 +34,19 @@ function Get-UserSelection {
[string]$DefaultChoice = 'A', [string]$DefaultChoice = 'A',
[bool]$AllowMultipleSelections = $true [bool]$AllowMultipleSelections = $true
) )
Write-Log "$Prompt`n" -Level 'PROMPT' Write-Log "$Prompt`n" -Level 'PROMPT'
for ($I = 0; $I -lt $Options.Length; $I++) { for ($I = 0; $I -lt $Options.Length; $I++) {
Write-Log "$([char](65 + $I)). $($Options[$I])" -Level 'PROMPT' Write-Log "$([char](65 + $I)). $($Options[$I])" -Level 'PROMPT'
} }
if ($AllowMultipleSelections) { if ($AllowMultipleSelections) {
Write-Log "`nSelect one or more options by typing the corresponding letters, separated by commas." -Level 'PROMPT' Write-Log "`nSelect one or more options by typing the corresponding letters, separated by commas." -Level 'PROMPT'
} }
else { else {
Write-Log "`nSelect an option by typing the corresponding letter." -Level 'PROMPT' Write-Log "`nSelect an option by typing the corresponding letter." -Level 'PROMPT'
} }
[string]$UserInput = Read-Host [string]$UserInput = Read-Host
if ([string]::IsNullOrEmpty($UserInput)) { if ([string]::IsNullOrEmpty($UserInput)) {
$UserInput = $DefaultChoice $UserInput = $DefaultChoice
@@ -125,7 +125,7 @@ function Test-PythonExecutable {
} }
else { else {
Write-Host "Deactivation script not found: $DeactivateVenv" Write-Host "Deactivation script not found: $DeactivateVenv"
} }
$PythonCmd = Get-Command $PythonExecutable -ErrorAction SilentlyContinue $PythonCmd = Get-Command $PythonExecutable -ErrorAction SilentlyContinue
if ($PythonCmd) { if ($PythonCmd) {
@@ -149,7 +149,7 @@ function Test-PythonExecutable {
function Find-PythonExecutable { function Find-PythonExecutable {
$PythonExecutables = @("python", "python3.12", "python3.11", "python3.10", "python3.9", "python3", "C:\Users\$env:USERNAME\AppData\Local\Programs\Python\Python312\python.exe", "C:\Users\$env:USERNAME\AppData\Local\Programs\Python\Python311\python.exe", "C:\Users\$env:USERNAME\AppData\Local\Programs\Python\Python310\python.exe", "C:\Users\$env:USERNAME\AppData\Local\Programs\Python\Python39\python.exe", "C:\Python311\python.exe", "C:\Python310\python.exe", "C:\Python39\python.exe") $PythonExecutables = @("python", "python3.12", "python3.11", "python3.10", "python3.9", "python3", "C:\Users\$env:USERNAME\AppData\Local\Programs\Python\Python312\python.exe", "C:\Users\$env:USERNAME\AppData\Local\Programs\Python\Python311\python.exe", "C:\Users\$env:USERNAME\AppData\Local\Programs\Python\Python310\python.exe", "C:\Users\$env:USERNAME\AppData\Local\Programs\Python\Python39\python.exe", "C:\Python311\python.exe", "C:\Python310\python.exe", "C:\Python39\python.exe")
foreach ($Executable in $PythonExecutables) { foreach ($Executable in $PythonExecutables) {
if (Test-PythonExecutable -PythonExecutable $Executable) { if (Test-PythonExecutable -PythonExecutable $Executable) {
return $Executable return $Executable
@@ -196,7 +196,7 @@ function Main {
Write-Log "Failed to activate virtual environment." -Level 'ERROR' Write-Log "Failed to activate virtual environment." -Level 'ERROR'
Exit-Script -exitCode 1 Exit-Script -exitCode 1
} }
# Ensure pip # Ensure pip
python -m ensurepip --default-pip 2>&1 | Out-File $LogFilePath -Append python -m ensurepip --default-pip 2>&1 | Out-File $LogFilePath -Append
@@ -255,33 +255,33 @@ function Main {
} }
$UiOptions = @("Yes", "No") $UiOptions = @("Yes", "No")
$InstallUi = Get-UserSelection -prompt "Do you want to install the freqtrade UI?" -options $UiOptions -defaultChoice 'B' -allowMultipleSelections $false $InstallUi = Get-UserSelection -prompt "Do you want to install the freqUI?" -options $UiOptions -defaultChoice 'B' -allowMultipleSelections $false
if ($InstallUi -eq 0) { if ($InstallUi -eq 0) {
# User selected "Yes" # User selected "Yes"
# Install freqtrade UI using the virtual environment's install-ui command # Install freqUI using the virtual environment's install-ui command
Write-Log "Installing freqtrade UI..." Write-Log "Installing freqUI..."
python freqtrade install-ui 2>&1 | Out-File $LogFilePath -Append python freqtrade install-ui 2>&1 | Out-File $LogFilePath -Append
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
Write-Log "Failed to install freqtrade UI." -Level 'ERROR' Write-Log "Failed to install freqUI." -Level 'ERROR'
Exit-Script -exitCode 1 Exit-Script -exitCode 1
} }
} }
elseif ($InstallUi -eq 1) { elseif ($InstallUi -eq 1) {
# User selected "No" # User selected "No"
# Skip installing freqtrade UI # Skip installing freqUI
Write-Log "Skipping freqtrade UI installation." Write-Log "Skipping freqUI installation."
} }
else { else {
# Invalid Selection # Invalid Selection
# Handle the error case # Handle the error case
Write-Log "Invalid Selection for freqtrade UI installation." -Level 'ERROR' Write-Log "Invalid Selection for freqUI installation." -Level 'ERROR'
Exit-Script -exitCode 1 Exit-Script -exitCode 1
} }
Write-Log "Update complete!" Write-Log "Update complete!"
Exit-Script -exitCode 0 Exit-Script -exitCode 0
} }
# Call the Main function # Call the Main function
Main Main