webui.bat 1.4 KB
Newer Older
1 2
@echo off

3 4
if not defined PYTHON (set PYTHON=python)
if not defined VENV_DIR (set VENV_DIR=venv)
D
Daniel Grenner 已提交
5

D
DepFA 已提交
6 7
set ERROR_REPORTING=FALSE

8 9 10
mkdir tmp 2>NUL

%PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt
11
if %ERRORLEVEL% == 0 goto :start_venv
12 13 14
echo Couldn't launch python
goto :show_stdout_stderr

15
:start_venv
16
if [%VENV_DIR%] == [-] goto :skip_venv
A
AUTOMATIC 已提交
17 18 19 20

dir %VENV_DIR%\Scripts\Python.exe >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :activate_venv

21
for /f "delims=" %%i in ('CALL %PYTHON% -c "import sys; print(sys.executable)"') do set PYTHON_FULLNAME="%%i"
A
AUTOMATIC 已提交
22 23 24 25 26 27 28
echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME%
%PYTHON_FULLNAME% -m venv %VENV_DIR% >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :activate_venv
echo Unable to create venv in directory %VENV_DIR%
goto :show_stdout_stderr

:activate_venv
29
set PYTHON="%~dp0%VENV_DIR%\Scripts\Python.exe"
A
AUTOMATIC 已提交
30
echo venv %PYTHON%
31
goto :launch
A
AUTOMATIC 已提交
32 33

:skip_venv
A
AUTOMATIC 已提交
34

35
:launch
D
DepFA 已提交
36
%PYTHON% launch.py %*
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
pause
exit /b

:show_stdout_stderr

echo.
echo exit code: %errorlevel%

for /f %%i in ("tmp\stdout.txt") do set size=%%~zi
if %size% equ 0 goto :show_stderr
echo.
echo stdout:
type tmp\stdout.txt

:show_stderr
for /f %%i in ("tmp\stderr.txt") do set size=%%~zi
if %size% equ 0 goto :show_stderr
echo.
echo stderr:
type tmp\stderr.txt

:endofscript

echo.
echo Launch unsuccessful. Exiting.
A
AUTOMATIC 已提交
62
pause