-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.bat
More file actions
91 lines (78 loc) · 2.77 KB
/
Copy pathrun.bat
File metadata and controls
91 lines (78 loc) · 2.77 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
@echo off
REM ============================================
REM ShipNetMonitor — Windows Launcher
REM Creates .venv, installs deps, runs the app.
REM ============================================
echo.
echo ==========================================
echo ShipNetMonitor - Marine Internet Monitor
echo ==========================================
echo.
REM Remember script directory (with trailing backslash)
set "SCRIPT_DIR=%~dp0"
REM --- Check Python ---
set "PYTHON_CMD="
where py >nul 2>&1
if not errorlevel 1 (
py -3.12 -c "import sys; raise SystemExit(0 if sys.version_info >= (3, 11) else 1)" >nul 2>&1
if not errorlevel 1 set "PYTHON_CMD=py -3.12"
if not defined PYTHON_CMD (
py -3.11 -c "import sys; raise SystemExit(0 if sys.version_info >= (3, 11) else 1)" >nul 2>&1
if not errorlevel 1 set "PYTHON_CMD=py -3.11"
)
)
if not defined PYTHON_CMD (
where python >nul 2>&1
if not errorlevel 1 (
python -c "import sys; raise SystemExit(0 if sys.version_info >= (3, 11) else 1)" >nul 2>&1
if not errorlevel 1 set "PYTHON_CMD=python"
)
)
if not defined PYTHON_CMD (
echo [ERROR] Python not found in PATH.
echo Install Python 3.11+ from https://www.python.org/downloads/
echo Make sure to check "Add Python to PATH" during installation.
echo.
pause
exit /b 1
)
for /f "tokens=*" %%i in ('%PYTHON_CMD% -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')"') do set PYVER=%%i
echo Found Python %PYVER%
echo.
REM --- Create virtual environment if needed ---
if not exist "%SCRIPT_DIR%.venv" (
echo [1/3] Creating virtual environment...
%PYTHON_CMD% -m venv "%SCRIPT_DIR%.venv"
if errorlevel 1 (
echo [ERROR] Failed to create virtual environment.
pause
exit /b 1
)
echo Done.
) else (
echo [1/3] Virtual environment already exists.
)
echo.
REM --- Activate venv and install dependencies ---
call "%SCRIPT_DIR%.venv\Scripts\activate.bat"
echo [2/3] Installing / updating dependencies...
python -m pip install --upgrade pip --quiet 2>nul
python -m pip install -r "%SCRIPT_DIR%requirements.txt" --quiet --trusted-host pypi.org --trusted-host files.pythonhosted.org
if errorlevel 1 (
echo [WARN] Some packages may have failed. Trying without --quiet...
python -m pip install -r "%SCRIPT_DIR%requirements.txt" --trusted-host pypi.org --trusted-host files.pythonhosted.org
)
echo Done.
echo.
REM --- Launch the application ---
echo [3/3] Starting ShipNetMonitor...
echo.
echo ==========================================
echo App is running. Close this window or
echo press Ctrl+C to stop.
echo ==========================================
echo.
python "%SCRIPT_DIR%shipnet.pyw"
echo.
echo ShipNetMonitor has exited.
pause