Files
future-map-OPEN/scripts/future-map-insights-hub/run_daily.ps1
T
2026-08-12 13:34:45 -06:00

27 lines
1.1 KiB
PowerShell

param(
[string]$PythonExecutable = "C:\Users\edsoe\AppData\Local\Programs\Python\Python313\python.exe"
)
$ErrorActionPreference = "Stop"
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path
$repositoryRoot = (Resolve-Path (Join-Path $scriptDirectory "..\..")).Path
$publisher = Join-Path $scriptDirectory "publish_future_map_insights.py"
$logDirectory = Join-Path $repositoryRoot "logs"
$logFile = Join-Path $logDirectory ("future-map-insights-hub-" + (Get-Date -Format "yyyy-MM-dd") + ".log")
New-Item -ItemType Directory -Path $logDirectory -Force | Out-Null
$started = Get-Date -Format "yyyy-MM-dd HH:mm:ss zzz"
"[$started] Starting Future Map Insights Hub publication." | Set-Content -LiteralPath $logFile -Encoding utf8
$publisherOutput = & $PythonExecutable $publisher 2>&1
$exitCode = $LASTEXITCODE
$publisherOutput | Add-Content -LiteralPath $logFile -Encoding utf8
$finished = Get-Date -Format "yyyy-MM-dd HH:mm:ss zzz"
"[$finished] Finished with exit code $exitCode." | Add-Content -LiteralPath $logFile -Encoding utf8
if ($exitCode -ne 0) {
throw "Future Map Insights Hub publication failed with exit code $exitCode. See $logFile"
}