-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdate.bat
More file actions
43 lines (37 loc) · 2.79 KB
/
Copy pathUpdate.bat
File metadata and controls
43 lines (37 loc) · 2.79 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
@echo off
setlocal EnableExtensions
title DAPI Biomass Counter - Update
cd /d "%~dp0"
echo ==================================================
echo Updating DAPI Biomass Counter
echo ==================================================
echo.
echo This downloads the newest version of the program from
echo the internet. Your saved images, your settings and the
echo Cellpose model are NOT changed.
echo.
powershell -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference='Stop'; $ProgressPreference='SilentlyContinue'; try { [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; $url='https://github.com/Etele8/DAPI/archive/refs/heads/master.zip'; $tmp=Join-Path $env:TEMP ('dapi_upd_'+[guid]::NewGuid().ToString('N')); New-Item -ItemType Directory -Path $tmp | Out-Null; $zip=Join-Path $tmp 'src.zip'; Write-Host ' Downloading...'; Invoke-WebRequest -Uri $url -OutFile $zip -UseBasicParsing; Write-Host ' Extracting...'; Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory($zip,$tmp); $r=Join-Path $tmp 'DAPI-master'; Write-Host ' Installing files...'; Copy-Item (Join-Path $r 'Install.bat') '.' -Force; Copy-Item (Join-Path $r 'Start DAPI Biomass Counter.bat') '.' -Force; Copy-Item (Join-Path $r 'Capture from Olympus.bat') '.' -Force; Copy-Item (Join-Path $r 'Update.bat') '.' -Force; Copy-Item (Join-Path $r 'requirements-ui.txt') '.' -Force; if(!(Test-Path 'app')){ New-Item -ItemType Directory 'app' | Out-Null }; Copy-Item (Join-Path $r 'app\*') 'app' -Recurse -Force; if(!(Test-Path 'src')){ New-Item -ItemType Directory 'src' | Out-Null }; Copy-Item (Join-Path $r 'src\*') 'src' -Recurse -Force; if(!(Test-Path 'tools')){ New-Item -ItemType Directory 'tools' | Out-Null }; Copy-Item (Join-Path $r 'tools\*') 'tools' -Recurse -Force; try { $c=Invoke-RestMethod -Uri 'https://api.github.com/repos/Etele8/DAPI/commits/master' -Headers @{'User-Agent'='dapi-updater'}; ($c.sha.Substring(0,7)+' '+$c.commit.author.date) | Out-File -Encoding ascii 'app\VERSION.txt' } catch {}; Remove-Item $tmp -Recurse -Force; Write-Host ' OK'; } catch { Write-Host ''; Write-Host (' UPDATE FAILED: '+$_.Exception.Message); exit 1 }"
if errorlevel 1 goto failed
echo.
echo Refreshing components (quick)...
if exist ".venv\Scripts\python.exe" ".venv\Scripts\python.exe" -m pip install -q -r requirements-ui.txt
echo.
echo ==================================================
echo Update complete.
echo ==================================================
if exist "app\VERSION.txt" (
echo Installed version:
type "app\VERSION.txt"
)
echo.
echo Close this window, then start the program as usual.
echo.
pause
exit /b 0
:failed
echo.
echo Could not update. Check the internet connection and
echo try again. Your current version still works fine.
echo.
pause
exit /b 1