Merge pull request #132 from bucolucas/feature/add-test-check-to-restart-script
Add test check before running the main Python script
This commit is contained in:
@@ -9,14 +9,30 @@ function Run-PythonScript {
|
||||
return $process.ExitCode
|
||||
}
|
||||
|
||||
function Run-Tests {
|
||||
$process = Start-Process -FilePath "powershell" -ArgumentList "-File run_tests.ps1" -PassThru -Wait -NoNewWindow
|
||||
return $process.ExitCode
|
||||
}
|
||||
|
||||
function Git-Pull {
|
||||
git pull
|
||||
return $LASTEXITCODE -eq 0
|
||||
}
|
||||
|
||||
$waitTime = 15
|
||||
$waitTime = 30
|
||||
while ($true) {
|
||||
python -m pip install -r requirements.txt
|
||||
|
||||
Write-Host "Running tests..."
|
||||
$testExitCode = Run-Tests
|
||||
if ($testExitCode -ne 0) {
|
||||
Write-Host "Tests failed. Attempting git pull and waiting $waitTime seconds before next attempt..."
|
||||
Git-Pull
|
||||
Start-Sleep -Seconds $waitTime
|
||||
continue
|
||||
}
|
||||
|
||||
Write-Host "Tests passed. Starting main Python script..."
|
||||
$exitCode = Run-PythonScript -ScriptPath $PythonFile
|
||||
|
||||
if (Test-Path -Path ".\.doreboot") {
|
||||
@@ -24,7 +40,6 @@ while ($true) {
|
||||
|
||||
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..."
|
||||
@@ -34,5 +49,4 @@ while ($true) {
|
||||
}
|
||||
|
||||
Start-Sleep -Seconds $waitTime
|
||||
$waitTime *= 2
|
||||
}
|
||||
Reference in New Issue
Block a user