-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_ui.ps1
More file actions
59 lines (51 loc) · 1.4 KB
/
Copy pathrun_ui.ps1
File metadata and controls
59 lines (51 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $root
function Resolve-Python {
$pythonCandidates = @(
(Join-Path $root ".venv\Scripts\python.exe"),
"python3",
"python",
"py"
)
foreach ($candidate in $pythonCandidates) {
if ($candidate -like "*.exe") {
if (-not (Test-Path $candidate)) {
continue
}
$pythonCmd = $candidate
}
else {
if (-not (Get-Command $candidate -ErrorAction SilentlyContinue)) {
continue
}
$pythonCmd = $candidate
}
try {
& $pythonCmd --version *> $null
if ($LASTEXITCODE -eq 0) {
return $pythonCmd
}
}
catch {
continue
}
}
return $null
}
$pythonCmd = Resolve-Python
if (-not $pythonCmd) {
throw "Python was not found. Create .venv or install Python and add it to PATH."
}
Write-Host "Launching VideoToScreensaver UI..." -ForegroundColor Cyan
try {
& $pythonCmd "src\app.py"
}
catch {
$message = $_.Exception.Message
if ($message -match "No module named") {
Write-Host "Missing dependencies. Install them with:" -ForegroundColor Yellow
Write-Host " python -m pip install -r requirements.txt" -ForegroundColor Yellow
}
throw
}