-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinaries_extract.bat
More file actions
57 lines (45 loc) · 2.07 KB
/
Copy pathbinaries_extract.bat
File metadata and controls
57 lines (45 loc) · 2.07 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
@echo off
setlocal EnableDelayedExpansion
:: Paths
set "componentsPath=%~dp0ext_components"
set "zipFile=%~dp0components.zip"
set "downloadUrl=https://github.com/ramjke/Translumo/releases/download/v.0.8.5/_components_v.1.0.0.zip"
set "targetPaths[0]=%~1python\"
set "targetPaths[1]=%~1models\easyocr\"
set "targetPaths[2]=%~1models\tessdata\"
set "targetPaths[3]=%~1models\prediction\"
set "inputBinariesPaths[0]=%componentsPath%\python"
set "inputBinariesPaths[1]=%componentsPath%\models\easyocr"
set "inputBinariesPaths[2]=%componentsPath%\models\tessdata"
set "inputBinariesPaths[3]=%componentsPath%\models\prediction"
echo Prebuild: Starting binaries downloading and extraction (binaries_extract.bat)...
:: Check if target folders already exist
set "allFoldersExist=1"
for %%i in (0,1,2,3) do if NOT exist "!targetPaths[%%i]!" set "allFoldersExist=0"
if "!allFoldersExist!"=="1" (
echo Folders exist in the target location. Extraction and copy skipped.
exit /b 0
)
:: Ensure components folder exists
if NOT exist "%componentsPath%" (
mkdir "%componentsPath%"
)
:TryExtract
echo Attempting to extract components.zip...
powershell -Command "try { Expand-Archive -Path '%zipFile%' -DestinationPath '%componentsPath%' -Force; Write-Output 'Extraction successful' } catch { exit 1 }"
if errorlevel 1 (
echo Zip missing or corrupted. Downloading components.zip...
if exist "%zipFile%" del "%zipFile%"
powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; try { Invoke-WebRequest '%downloadUrl%' -OutFile '%zipFile%'; Write-Output 'Download successful' } catch { Write-Output $_.Exception.Message; exit 1 }"
goto TryExtract
)
echo Copy binary/model folders to target locations...
for %%i in (0,1,2,3) do (
if NOT exist "!targetPaths[%%i]!" (
echo Path not found: !targetPaths[%%i]!
mkdir "!targetPaths[%%i]!" 2>nul
xcopy /s /y /i "!inputBinariesPaths[%%i]!" "!targetPaths[%%i]!"
)
)
echo Binaries downloading and extraction finished.
exit /b 0