Skip to content

Commit eaa516a

Browse files
committed
chore: Add build configuration files with proper icon
- Added NetworkMonitor.spec for PyInstaller build configuration - Added installer.nsi for NSIS installer creation - Added proper multi-resolution icon.ico (16,32,48,256px) - Updated .gitignore to track build configuration files
1 parent 26d03a0 commit eaa516a

4 files changed

Lines changed: 283 additions & 5 deletions

File tree

.gitignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,8 @@ htmlcov/
3636
.pytest_cache/
3737

3838
# Build artifacts
39-
*.spec
40-
installer.nsi
41-
*.ico
42-
assets/icon.ico
43-
assets/icon.png
39+
# Allow spec and nsi files for build configuration
40+
# assets/icon.* allowed for distribution
4441

4542
# Temporary files
4643
.tmp/

NetworkMonitor.spec

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
"""
3+
PyInstaller spec file for NetworkMonitor
4+
"""
5+
import os
6+
from PyInstaller.utils.hooks import collect_submodules
7+
8+
block_cipher = None
9+
10+
# Collect all scapy layers
11+
scapy_hiddenimports = collect_submodules('scapy.layers')
12+
13+
a = Analysis(
14+
['networkmonitor/__main__.py'],
15+
pathex=['.'],
16+
binaries=[],
17+
datas=[
18+
('assets/*', 'assets'),
19+
],
20+
hiddenimports=[
21+
'networkmonitor',
22+
'networkmonitor.server',
23+
'networkmonitor.monitor',
24+
'networkmonitor.launcher',
25+
'networkmonitor.dependency_check',
26+
'networkmonitor.npcap_helper',
27+
'networkmonitor.windows',
28+
'flask',
29+
'flask.cli',
30+
'flask_cors',
31+
'click',
32+
'werkzeug',
33+
'werkzeug.serving',
34+
'werkzeug.debug',
35+
'jinja2',
36+
'scapy',
37+
'scapy.all',
38+
'scapy.layers.l2',
39+
'scapy.layers.inet',
40+
'psutil',
41+
'requests',
42+
'wmi',
43+
'win32api',
44+
'win32com',
45+
'win32com.client',
46+
'win32com.shell',
47+
'pystray',
48+
'PIL',
49+
'PIL.Image',
50+
'engineio.async_drivers.threading',
51+
] + scapy_hiddenimports,
52+
hookspath=[],
53+
hooksconfig={},
54+
runtime_hooks=[],
55+
excludes=[
56+
'matplotlib',
57+
'numpy',
58+
'pandas',
59+
'scipy',
60+
'IPython',
61+
'jupyter',
62+
],
63+
cipher=block_cipher,
64+
noarchive=False,
65+
)
66+
67+
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
68+
69+
exe = EXE(
70+
pyz,
71+
a.scripts,
72+
a.binaries,
73+
a.zipfiles,
74+
a.datas,
75+
[],
76+
name='NetworkMonitor',
77+
debug=False,
78+
bootloader_ignore_signals=False,
79+
strip=False,
80+
upx=True,
81+
upx_exclude=[],
82+
runtime_tmpdir=None,
83+
console=True,
84+
disable_windowed_traceback=False,
85+
argv_emulation=False,
86+
target_arch=None,
87+
codesign_identity=None,
88+
entitlements_file=None,
89+
icon='assets/icon.ico',
90+
uac_admin=True,
91+
version='file_version_info.txt',
92+
)

assets/icon.ico

1.96 KB
Binary file not shown.

installer.nsi

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
; NetworkMonitor Installer Script
2+
; One-Click Installation for Non-Technical Users
3+
4+
!include "MUI2.nsh"
5+
!include "LogicLib.nsh"
6+
!include "WinVer.nsh"
7+
!include "x64.nsh"
8+
9+
; Product info
10+
!define PRODUCT_NAME "NetworkMonitor"
11+
!define PRODUCT_VERSION "0.1.0"
12+
!define PRODUCT_PUBLISHER "NetworkMonitor"
13+
!define PRODUCT_WEB_SITE "https://github.com/umerfarok/networkmonitor"
14+
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\NetworkMonitor.exe"
15+
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
16+
17+
; Modern UI settings
18+
!define MUI_ABORTWARNING
19+
!define MUI_ICON "assets\icon.ico"
20+
!define MUI_UNICON "assets\icon.ico"
21+
22+
; Welcome page customization
23+
!define MUI_WELCOMEPAGE_TITLE "Welcome to NetworkMonitor"
24+
!define MUI_WELCOMEPAGE_TEXT "This wizard will install NetworkMonitor on your computer.$\r$\n$\r$\nNetworkMonitor lets you:$\r$\n• See all devices on your network$\r$\n• Control device connections$\r$\n• Monitor bandwidth usage$\r$\n$\r$\nClick Next to continue."
25+
26+
; Finish page - auto launch
27+
!define MUI_FINISHPAGE_RUN "$INSTDIR\NetworkMonitor.exe"
28+
!define MUI_FINISHPAGE_RUN_TEXT "Launch NetworkMonitor now"
29+
!define MUI_FINISHPAGE_SHOWREADME ""
30+
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
31+
!define MUI_FINISHPAGE_LINK "Visit NetworkMonitor Website"
32+
!define MUI_FINISHPAGE_LINK_LOCATION "${PRODUCT_WEB_SITE}"
33+
34+
; Installer pages - simplified for non-technical users
35+
!insertmacro MUI_PAGE_WELCOME
36+
!insertmacro MUI_PAGE_INSTFILES
37+
!insertmacro MUI_PAGE_FINISH
38+
39+
; Uninstaller pages
40+
!insertmacro MUI_UNPAGE_CONFIRM
41+
!insertmacro MUI_UNPAGE_INSTFILES
42+
43+
; Language
44+
!insertmacro MUI_LANGUAGE "English"
45+
46+
; Installer attributes
47+
Name "${PRODUCT_NAME}"
48+
OutFile "dist\NetworkMonitor-Setup-${PRODUCT_VERSION}.exe"
49+
InstallDir "$PROGRAMFILES64\NetworkMonitor"
50+
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
51+
ShowInstDetails nevershow ; Hide details for non-technical users
52+
ShowUnInstDetails nevershow
53+
RequestExecutionLevel admin
54+
55+
; Variables
56+
Var NpcapInstalled
57+
58+
Function .onInit
59+
; Check Windows version
60+
${IfNot} ${AtLeastWin10}
61+
MessageBox MB_OK|MB_ICONSTOP "NetworkMonitor requires Windows 10 or later.$\r$\n$\r$\nPlease upgrade your Windows version."
62+
Abort
63+
${EndIf}
64+
65+
; Check if running on 64-bit Windows
66+
${IfNot} ${RunningX64}
67+
MessageBox MB_OK|MB_ICONSTOP "NetworkMonitor requires 64-bit Windows.$\r$\n$\r$\nYour system appears to be 32-bit."
68+
Abort
69+
${EndIf}
70+
71+
; Check if running with admin privileges
72+
UserInfo::GetAccountType
73+
Pop $0
74+
${If} $0 != "admin"
75+
MessageBox MB_OK|MB_ICONSTOP "Please right-click the installer and select 'Run as administrator'."
76+
Abort
77+
${EndIf}
78+
79+
; Check if Npcap is already installed
80+
StrCpy $NpcapInstalled "0"
81+
82+
; Check for Npcap DLL
83+
IfFileExists "$SYSDIR\Npcap\wpcap.dll" 0 +2
84+
StrCpy $NpcapInstalled "1"
85+
86+
; Also check WinPcap compatibility location
87+
IfFileExists "$SYSDIR\wpcap.dll" 0 +3
88+
StrCpy $NpcapInstalled "1"
89+
FunctionEnd
90+
91+
Section "NetworkMonitor" SEC_CORE
92+
SectionIn RO
93+
94+
; Show progress
95+
DetailPrint "Installing NetworkMonitor..."
96+
SetOutPath "$INSTDIR"
97+
98+
; Main executable (single-file build)
99+
File "dist\NetworkMonitor.exe"
100+
101+
; Copy icon for shortcuts
102+
File "assets\icon.ico"
103+
104+
; Create shortcuts
105+
DetailPrint "Creating shortcuts..."
106+
CreateDirectory "$SMPROGRAMS\NetworkMonitor"
107+
CreateShortCut "$SMPROGRAMS\NetworkMonitor\NetworkMonitor.lnk" "$INSTDIR\NetworkMonitor.exe" "" "$INSTDIR\NetworkMonitor.exe" 0
108+
CreateShortCut "$SMPROGRAMS\NetworkMonitor\Uninstall.lnk" "$INSTDIR\uninstall.exe"
109+
CreateShortCut "$DESKTOP\NetworkMonitor.lnk" "$INSTDIR\NetworkMonitor.exe" "" "$INSTDIR\NetworkMonitor.exe" 0
110+
111+
; Write registry keys
112+
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\NetworkMonitor.exe"
113+
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME}"
114+
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninstall.exe"
115+
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\NetworkMonitor.exe"
116+
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
117+
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
118+
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
119+
WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoModify" 1
120+
WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoRepair" 1
121+
122+
; Create uninstaller
123+
WriteUninstaller "$INSTDIR\uninstall.exe"
124+
125+
; Install Npcap if not present
126+
${If} $NpcapInstalled == "0"
127+
DetailPrint "Installing network driver (Npcap)..."
128+
DetailPrint "This may take a minute..."
129+
130+
SetOutPath "$TEMP\NetworkMonitor"
131+
File "bundled_resources\Npcap\npcap-installer.exe"
132+
133+
; Silent install with WinPcap compatibility mode
134+
ExecWait '"$TEMP\NetworkMonitor\npcap-installer.exe" /S /winpcap_mode=yes' $0
135+
136+
${If} $0 != 0
137+
MessageBox MB_OK|MB_ICONEXCLAMATION "Npcap installation may have failed.$\r$\n$\r$\nIf NetworkMonitor doesn't work, please install Npcap manually from npcap.com"
138+
${EndIf}
139+
140+
Delete "$TEMP\NetworkMonitor\npcap-installer.exe"
141+
RMDir "$TEMP\NetworkMonitor"
142+
${Else}
143+
DetailPrint "Network driver already installed (Npcap/WinPcap found)"
144+
${EndIf}
145+
146+
; Install VC++ Runtime if bundled
147+
IfFileExists "bundled_resources\vcruntime\vc_redist.x64.exe" 0 SkipVCRuntime
148+
DetailPrint "Installing Visual C++ Runtime..."
149+
SetOutPath "$TEMP\NetworkMonitor"
150+
File "bundled_resources\vcruntime\vc_redist.x64.exe"
151+
ExecWait '"$TEMP\NetworkMonitor\vc_redist.x64.exe" /quiet /norestart'
152+
Delete "$TEMP\NetworkMonitor\vc_redist.x64.exe"
153+
RMDir "$TEMP\NetworkMonitor"
154+
SkipVCRuntime:
155+
156+
; Add firewall exception
157+
DetailPrint "Configuring firewall..."
158+
nsExec::ExecToLog 'netsh advfirewall firewall add rule name="NetworkMonitor API" dir=in action=allow program="$INSTDIR\NetworkMonitor.exe" enable=yes'
159+
nsExec::ExecToLog 'netsh advfirewall firewall add rule name="NetworkMonitor Port 5000" dir=in action=allow protocol=TCP localport=5000'
160+
161+
DetailPrint "Installation complete!"
162+
SectionEnd
163+
164+
Section "Uninstall"
165+
; Remove firewall rules
166+
nsExec::ExecToLog 'netsh advfirewall firewall delete rule name="NetworkMonitor API"'
167+
nsExec::ExecToLog 'netsh advfirewall firewall delete rule name="NetworkMonitor Port 5000"'
168+
169+
; Remove application files
170+
Delete "$INSTDIR\NetworkMonitor.exe"
171+
Delete "$INSTDIR\uninstall.exe"
172+
RMDir /r "$INSTDIR"
173+
174+
; Remove shortcuts
175+
Delete "$SMPROGRAMS\NetworkMonitor\NetworkMonitor.lnk"
176+
Delete "$SMPROGRAMS\NetworkMonitor\Uninstall.lnk"
177+
Delete "$DESKTOP\NetworkMonitor.lnk"
178+
RMDir "$SMPROGRAMS\NetworkMonitor"
179+
180+
; Remove registry keys
181+
DeleteRegKey HKLM "${PRODUCT_UNINST_KEY}"
182+
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
183+
SectionEnd
184+
185+
; Description for components (not shown but required)
186+
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
187+
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_CORE} "NetworkMonitor application and all required components"
188+
!insertmacro MUI_FUNCTION_DESCRIPTION_END
189+

0 commit comments

Comments
 (0)