This repository was archived by the owner on May 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bat
93 lines (83 loc) · 2.42 KB
/
build.bat
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
cd "%~dp0"
:: Create virtualenv
pip3 install --upgrade virtualenv
rmdir /S /Q venv
virtualenv venv
venv\Scripts\python setup.py install
:: Syntax test the script
venv\Scripts\python SharkScout.py -h > nul
if %errorlevel% neq 0 (
rmdir /S /Q venv
exit /B 1
)
:: Run pyinstaller
rmdir /S /Q dist
venv\Scripts\pip3 install pyinstaller
venv\Scripts\pyinstaller --noconfirm --clean --onefile --add-data "config.json;." --hidden-import "statistics" --icon "venv\Scripts\python.exe,0" SharkScout.py
del /F SharkScout.spec
rmdir /S /Q __pycache__
rmdir /S /Q build
:: Syntax test the compiled script
cd dist
SharkScout.exe -h
if %errorlevel% neq 0 (
cd ..
rmdir /S /Q dist
rmdir /S /Q venv
exit /B 1
)
cd ..
:: Copy files for distribution
copy LICENSE* dist\
copy README* dist\
echo .rar\ > exclude
xcopy www dist\www /S /V /I /Y /EXCLUDE:exclude
del /F exclude
copy /Y build-mongodump.gz dist\mongodump.gz
cd dist
:: Run the test script (fast check before TBA update)
..\venv\Scripts\pip3 install requests pynumparser scrapy
..\venv\Scripts\python ..\SharkScout-Test.py --level 1 SharkScout.exe --port 22600 --no-browser
if %errorlevel% neq 0 (
cd ..
rmdir /S /Q dist
rmdir /S /Q venv
exit /B 1
)
:: Export TBA data for last year through next year
for /f "skip=1 tokens=1-6" %%A in ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') do (
if "%%B" NEQ "" (
set /A FDATE=%%F*10000+%%D*100+%%A
set /A FTIME=%%B*10000+%%C*100+%%E
)
)
set YEAR_CURR=%FDATE:~0,4%
set /A YEAR_PREV=%YEAR_CURR%-1
set /A YEAR_NEXT=%YEAR_CURR%+1
SharkScout.exe --update-teams --update-teams-info --update-events "1992-%YEAR_NEXT%" --update-events-info "%YEAR_PREV%-%YEAR_NEXT%" --dump mongodump.gz
if %errorlevel% neq 0 (
cd ..
rmdir /S /Q dist
rmdir /S /Q venv
exit /B 1
)
:: Run the test script
..\venv\Scripts\python ..\SharkScout-Test.py --level 2 SharkScout.exe --port 22600 --no-browser
if %errorlevel% neq 0 (
cd ..
rmdir /S /Q dist
rmdir /S /Q venv
exit /B 1
)
rmdir /S /Q mongo
rmdir /S /Q sessions
cd ..
rmdir /S /Q venv
:: Make a distribution zip
for /f %%i in ('git rev-parse HEAD') do set HASH=%%i
del /F SharkScout-%HASH:~0,7%-x86.zip
powershell -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::CreateFromDirectory('dist', 'SharkScout-%HASH:~0,7%-x86.zip'); }"
if %errorlevel% equ 0 (
copy /Y dist\mongodump.gz build-mongodump.gz
rmdir /S /Q dist
)