# Juno contest reader: install the latest reader from the site (uses the token in config.json). $ProgressPreference = "SilentlyContinue" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $dir = "C:\juno-reader" $cfg = Get-Content "$dir\config.json" -Raw | ConvertFrom-Json $pkg = Invoke-RestMethod "$($cfg.api)/reader/package" -Headers @{ Authorization = "Bearer $($cfg.token)" } $allowed = "juno_reader.py", "requirements.txt", "README.md", "test_clock.py" foreach ($f in $pkg.files.PSObject.Properties) { if ($allowed -notcontains $f.Name) { continue } $target = Join-Path $dir $f.Name if (Test-Path $target) { Copy-Item $target "$target.bak" -Force } [IO.File]::WriteAllBytes($target, [Convert]::FromBase64String($f.Value)) } Write-Host "Installed reader $($pkg.version)" -ForegroundColor Green Stop-ScheduledTask -TaskName "Juno Contest Reader" Start-Sleep 3 Start-ScheduledTask -TaskName "Juno Contest Reader" Start-Sleep 25 Get-Content "$dir\reader.log" -Tail 3 Write-Host "Done. From now on: python juno_reader.py update" -ForegroundColor Green