Tighten cutter phase span validation

This commit is contained in:
Melbar
2026-05-08 14:56:44 +02:00
parent 10e27afc8d
commit acafe538b2
8 changed files with 52 additions and 13 deletions
+33 -5
View File
@@ -7,6 +7,34 @@
$ErrorActionPreference = "Stop"
$VENV_DIR = ".venv"
function Invoke-CapturedProcess {
param(
[Parameter(Mandatory = $true)][string]$FilePath,
[Parameter(Mandatory = $false)][string[]]$Arguments = @()
)
$psi = [System.Diagnostics.ProcessStartInfo]::new()
$psi.FileName = $FilePath
foreach ($arg in $Arguments) {
[void]$psi.ArgumentList.Add($arg)
}
$psi.UseShellExecute = $false
$psi.RedirectStandardOutput = $true
$psi.RedirectStandardError = $true
$psi.CreateNoWindow = $true
$process = [System.Diagnostics.Process]::Start($psi)
$stdout = $process.StandardOutput.ReadToEnd()
$stderr = $process.StandardError.ReadToEnd()
$process.WaitForExit()
$combined = (($stdout + "`n" + $stderr).Trim())
if ($process.ExitCode -ne 0) {
throw "Command failed ($($process.ExitCode)): $FilePath $($Arguments -join ' ')`n$combined"
}
return $combined
}
function Resolve-ProjectPython {
$cmd = Get-Command python -ErrorAction SilentlyContinue
if ($cmd) {
@@ -35,7 +63,7 @@ Write-Host ""
# ---- 1. Check Python version ------------------------------------------------
$PROJECT_PYTHON = Resolve-ProjectPython
$pythonVersion = & $PROJECT_PYTHON --version 2>&1
$pythonVersion = Invoke-CapturedProcess $PROJECT_PYTHON @("--version")
Write-Host "Python: $pythonVersion"
if ($pythonVersion -notmatch "3\.(1[1-9]|[2-9]\d)") {
Write-Error "Python 3.11+ required. Found: $pythonVersion"
@@ -48,8 +76,8 @@ if (Test-Path $VENV_DIR) {
$venvOk = $false
if (Test-Path $existingVenvPython) {
try {
$existingVersion = & $existingVenvPython --version 2>&1
$venvOk = $LASTEXITCODE -eq 0 -and $existingVersion -match "3\.(1[1-9]|[2-9]\d)"
$existingVersion = Invoke-CapturedProcess $existingVenvPython @("--version")
$venvOk = $existingVersion -match "3\.(1[1-9]|[2-9]\d)"
} catch {
$venvOk = $false
}
@@ -60,12 +88,12 @@ if (Test-Path $VENV_DIR) {
} else {
Write-Host "Existing virtual environment is not usable. Recreating '$VENV_DIR' ..." -ForegroundColor Yellow
Remove-Item -LiteralPath $VENV_DIR -Recurse -Force
& $PROJECT_PYTHON -m venv $VENV_DIR
Invoke-CapturedProcess $PROJECT_PYTHON @("-m", "venv", $VENV_DIR) | Out-Null
Write-Host "Done." -ForegroundColor Green
}
} else {
Write-Host "Creating virtual environment in '$VENV_DIR' ..." -ForegroundColor Green
& $PROJECT_PYTHON -m venv $VENV_DIR
Invoke-CapturedProcess $PROJECT_PYTHON @("-m", "venv", $VENV_DIR) | Out-Null
Write-Host "Done." -ForegroundColor Green
}