Repository navigation
Expand file tree
/
Copy pathstart-wb-proxy.bat
More file actions
104 lines (89 loc) · 2.59 KB
/
Copy pathstart-wb-proxy.bat
File metadata and controls
104 lines (89 loc) · 2.59 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
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
94
95
96
97
98
99
100
101
102
103
104
@echo off
setlocal EnableExtensions
rem ===========================================================
rem WorkBuddy international proxy - launcher
rem Usage: double-click, or start-wb-proxy.bat [port]
rem
rem ASCII-only on purpose: .bat files are read using the
rem console code page, so non-ASCII text breaks the parser.
rem
rem NOTE: this script puts no %VAR% inside an if( ... ) block,
rem because a path containing ( or ) breaks the cmd.exe parser.
rem All checks use if/errorlevel/goto instead.
rem ===========================================================
set "PORT=%~1"
if "%PORT%"=="" set "PORT=8788"
set "HERE=%~dp0"
set "SCRIPT=%HERE%wb_proxy.py"
if not exist "%SCRIPT%" goto no_script
set "PYEXE="
rem ---- 1) bundled runtime (ships with the zip) ----
if not exist "%HERE%python\python.exe" goto try_path
"%HERE%python\python.exe" --version >nul 2>nul
if errorlevel 1 goto try_path
set "PYEXE=%HERE%python\python.exe"
goto run
:try_path
rem ---- 2) python on PATH ----
python --version >nul 2>nul
if errorlevel 1 goto try_py
set "PYEXE=python"
goto run
:try_py
rem ---- 3) py launcher ----
py --version >nul 2>nul
if errorlevel 1 goto try_codex
set "PYEXE=py"
goto run
:try_codex
rem ---- 4) Codex bundled runtimes ----
call :find_codex
if defined PYEXE goto run
echo [ERROR] No usable Python found.
echo.
echo Options:
echo 1. Use the packaged zip, which already contains python\
echo 2. Install Python 3.9+ from https://www.python.org/downloads/
echo (tick "Add python.exe to PATH" during setup)
echo 3. Edit this file and set PYEXE to a full path, e.g.
echo set "PYEXE=C:\Python312\python.exe"
echo.
pause
exit /b 1
:no_script
echo [ERROR] wb_proxy.py not found next to this script.
echo expected: %SCRIPT%
echo.
pause
exit /b 1
:find_codex
if not exist "%USERPROFILE%\.cache\codex-runtimes" goto :eof
for /d %%D in ("%USERPROFILE%\.cache\codex-runtimes\*") do call :probe "%%~D"
goto :eof
:probe
if defined PYEXE goto :eof
for /f "delims=" %%P in ('dir /b /s "%~1\python.exe" 2^>nul') do call :probe_one "%%~P"
goto :eof
:probe_one
if defined PYEXE goto :eof
"%~1" --version >nul 2>nul
if errorlevel 1 goto :eof
set "PYEXE=%~1"
goto :eof
:run
echo ===========================================================
echo WorkBuddy proxy
echo.
echo API : http://127.0.0.1:%PORT%/v1
echo Dashboard: http://127.0.0.1:%PORT%/
echo.
echo Python : %PYEXE%
echo.
echo Keep this window open. Closing it stops the server.
echo Press Ctrl+C to stop.
echo ===========================================================
echo.
"%PYEXE%" "%SCRIPT%" --port %PORT%
echo.
echo [server exited]
pause