diff --git a/application/src/backend_proxy.py b/application/src/backend_proxy.py index ce5f4e1..bcb6c9c 100644 --- a/application/src/backend_proxy.py +++ b/application/src/backend_proxy.py @@ -3,7 +3,7 @@ try: except: class aostats: # type: ignore @staticmethod - def initialize(_): + def initialize(): return InitializationResult.NetworkInterfaceListMissing @staticmethod diff --git a/application/src/gui/app.py b/application/src/gui/app.py index 4180a19..589a5e1 100644 --- a/application/src/gui/app.py +++ b/application/src/gui/app.py @@ -5,6 +5,7 @@ from PySide2.QtCore import Qt # type: ignore from PySide2 import QtGui # type: ignore from PySide2.QtWidgets import QApplication # type: ignore from PySide2.QtWidgets import QMessageBox # type: ignore +from PySide2.QtWidgets import QPushButton # type: ignore from ..engine import InitializationResult from ..engine import initialize @@ -16,9 +17,13 @@ from ..utils.version import current_version as get_current_version from ..utils.version import latest_url from ..utils.version import latest_version as get_latest_version from ..utils.assets import path +from ..utils.assets import scripts sys.path.append(os.path.dirname(os.path.abspath('__file__'))) +def fix_npcap(): + os.system(scripts('fixnpcap.bat')) + sys.exit(0) def run(): initialization_result = initialize() @@ -70,9 +75,15 @@ def run(): msg.setWindowTitle("Unable to track network traffic data!") msg.setText( "On windows make sure that WinPcap is installed in your system.") - msg.setInformativeText("WinPcap can be installed from here
Make sure to install with the \"Install Npcap in WinPcap API-compatible Mode\" option" - .format('https://nmap.org/npcap/dist/npcap-0.9986.exe')) + msg.setInformativeText("WinPcap can be installed from here
\ + Make sure to install with the \"Install Npcap in WinPcap API-compatible Mode\" option

\ + In case where npcap is installed try to fix npcap and restart the app" + .format('https://nmap.org/npcap/dist/npcap-0.9990.exe')) msg.setStandardButtons(QMessageBox.Ok) + button = QPushButton("Fix npcap") + + button.clicked.connect(fix_npcap) + msg.addButton(button, QMessageBox.NoRole) msg.show() sys.exit(app.exec_()) diff --git a/application/src/scripts/fixnpcap.bat b/application/src/scripts/fixnpcap.bat new file mode 100644 index 0000000..5ff77dc --- /dev/null +++ b/application/src/scripts/fixnpcap.bat @@ -0,0 +1,6 @@ +@echo off +if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b) + +net stop npcap +net start npcap +pause diff --git a/application/src/utils/assets.py b/application/src/utils/assets.py index 4c50617..cf8529e 100644 --- a/application/src/utils/assets.py +++ b/application/src/utils/assets.py @@ -3,6 +3,13 @@ import os assets_path = os.path.join(os.path.dirname( os.path.abspath(__file__)), '..', 'assets') +scripts_path = os.path.join(os.path.dirname( + os.path.abspath(__file__)), '..', 'scripts') + def path(file): return os.path.join(assets_path, file) + + +def scripts(script_name): + return os.path.join(scripts_path, script_name) diff --git a/appveyor.yml b/appveyor.yml index cac9703..4098d86 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -39,7 +39,7 @@ build_script: - ps: .\env\Scripts\activate.ps1 - python -m pip install dataclasses - python -m pip install -v -r application\requirements.txt - - pyinstaller -F -w -i assets\albion-stats-icon.ico --add-data application\src\assets;src\assets application\albion-online-stats.py + - pyinstaller -F -w -i assets\albion-stats-icon.ico --add-data application\src\assets;src\assets --add-data application\src\scripts;src\scripts application\albion-online-stats.py - ps: deactivate after_build: - ps: mv dist\albion-online-stats.exe albion-online-stats.exe