2024-08-20 12:30:05 -05:00
|
|
|
param(
|
|
|
|
|
[Parameter(Mandatory=$true)]
|
2024-08-20 13:11:24 -05:00
|
|
|
[string]$PythonFile
|
2024-08-20 12:30:05 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
function Run-PythonScript {
|
|
|
|
|
param($ScriptPath)
|
|
|
|
|
$process = Start-Process -FilePath "python" -ArgumentList $ScriptPath -PassThru -Wait -NoNewWindow
|
|
|
|
|
return $process.ExitCode
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Git-Pull {
|
|
|
|
|
git pull
|
|
|
|
|
return $LASTEXITCODE -eq 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$waitTime = 15
|
2024-08-20 13:11:24 -05:00
|
|
|
while ($true) {
|
2024-08-20 17:10:30 -05:00
|
|
|
python -m pip install -r requirements.txt
|
2024-08-20 12:30:05 -05:00
|
|
|
$exitCode = Run-PythonScript -ScriptPath $PythonFile
|
|
|
|
|
|
2024-08-20 13:11:24 -05:00
|
|
|
if (Test-Path -Path ".\.doreboot") {
|
|
|
|
|
Write-Host "Special filename detected. Attempting git pull..."
|
2024-08-20 12:30:05 -05:00
|
|
|
|
|
|
|
|
if (Git-Pull) {
|
|
|
|
|
Write-Host "Git pull successful. Restarting Python script..."
|
|
|
|
|
$waitTime = 15
|
|
|
|
|
continue
|
|
|
|
|
} else {
|
|
|
|
|
Write-Host "Git pull failed. Waiting $waitTime seconds before next attempt..."
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2024-08-20 13:11:24 -05:00
|
|
|
exit 1
|
2024-08-20 12:30:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Start-Sleep -Seconds $waitTime
|
|
|
|
|
$waitTime *= 2
|
2024-08-20 13:11:24 -05:00
|
|
|
}
|