@echo off setlocal EnableExtensions DisableDelayedExpansion set "PROJECT_ROOT=%~dp0" set "PYTHON_EXE=%PROJECT_ROOT%.venv\Scripts\python.exe" cd /d "%PROJECT_ROOT%" || goto :cd_failed if not exist "%PYTHON_EXE%" goto :venv_missing rem Always run the current source tree instead of an older packaged EXE. set "PYTHONPATH=%PROJECT_ROOT%src" set "PYTHONUNBUFFERED=1" set "PYTHONDONTWRITEBYTECODE=1" rem Keep a dedicated debug profile, but reuse it so account/server preferences persist. set "DEBUG_PROFILE=%LOCALAPPDATA%\ZhenYangTang\DoctorWorkstation\Debug" if not defined LOCALAPPDATA set "DEBUG_PROFILE=%PROJECT_ROOT%.debug-profile" set "DOCTOR_CONFIG_DIR=%DEBUG_PROFILE%\config" set "DOCTOR_LOG_DIR=%DEBUG_PROFILE%\logs" set "DOCTOR_DEMO_MODE=true" set "DOCTOR_LOG_LEVEL=DEBUG" set "DOCTOR_VIDEO_MODE=embedded" if not exist "%DOCTOR_CONFIG_DIR%" mkdir "%DOCTOR_CONFIG_DIR%" >nul 2>&1 if not exist "%DOCTOR_LOG_DIR%" mkdir "%DOCTOR_LOG_DIR%" >nul 2>&1 echo ============================================================ echo Doctor Workstation - Source Debug Mode echo ============================================================ echo Project : %PROJECT_ROOT% echo Logs : %DOCTOR_LOG_DIR% echo Account : doctor echo Password: doctor123 echo ============================================================ echo. if /I "%~1"=="--check" goto :check "%PYTHON_EXE%" -X faulthandler -m doctor_workstation set "RESULT=%ERRORLEVEL%" if "%RESULT%"=="0" goto :success echo. echo [ERROR] Doctor Workstation exited with code %RESULT%. echo [INFO] Debug logs: %DOCTOR_LOG_DIR% echo Press any key to close this window. pause >nul endlocal & exit /b %RESULT% :check "%PYTHON_EXE%" -c "import doctor_workstation; from doctor_workstation.ui.theme import COLORS; print('DEBUG_LAUNCHER_OK', COLORS['canvas'])" set "RESULT=%ERRORLEVEL%" if not "%RESULT%"=="0" goto :check_failed echo. echo [OK] Source imports and debug environment are ready. endlocal & exit /b 0 :check_failed echo. echo [ERROR] Source import check failed with code %RESULT%. pause >nul endlocal & exit /b %RESULT% :success endlocal & exit /b 0 :venv_missing echo. echo [ERROR] Python virtual environment was not found: echo %PYTHON_EXE% echo. echo Create or restore app\.venv and install the project dependencies first. echo Press any key to close this window. pause >nul endlocal & exit /b 2 :cd_failed echo [ERROR] Could not enter the project directory: %PROJECT_ROOT% pause >nul endlocal & exit /b 3