Skip to content

Commit

Permalink
v1.2.8 - 05/12/2024 (15:56)
Browse files Browse the repository at this point in the history
* Refined/Improved: Code.
* Hotfixed: An issue where the script would crash at startup if setting `<CAPTURE_TSHARK_PATH>` was undefined. (#13).
  • Loading branch information
BUZZARDGTA committed Dec 5, 2024
1 parent 36bb3c0 commit 185a3ba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
17 changes: 12 additions & 5 deletions GTA_V_Session_Sniffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,8 @@ def truncate_with_ellipsis(string: str, max_length: int):
return string

def show_error__tshark_not_detected():
from Modules.consts import WIRESHARK_REQUIRED_DL

webbrowser.open(WIRESHARK_REQUIRED_DL)

msgbox_title = TITLE
Expand Down Expand Up @@ -1860,7 +1862,7 @@ def custom_str_to_nonetype(string: str):
os.chdir(SCRIPT_DIR)

TITLE = "GTA V Session Sniffer"
VERSION = "v1.2.7 - 05/12/2024 (14:15)"
VERSION = "v1.2.8 - 05/12/2024 (15:56)"
SETTINGS_PATH = Path("Settings.ini")

cls()
Expand Down Expand Up @@ -2044,11 +2046,14 @@ def check_packages_version(third_party_packages: dict[str, str]):
cls()
title(f"Checking that \"Tshark (Wireshark) v4.2.9\" is installed on your system - {TITLE}")
print("\nChecking that \"Tshark (Wireshark) v4.2.9\" is installed on your system ...\n")
from Modules.consts import WIRESHARK_REQUIRED_VERSION, WIRESHARK_REQUIRED_DL
from Modules.consts import WIRESHARK_REQUIRED_DL, WIRESHARK_REQUIRED_VERSION

while True:
try:
TSHARK_PATH = get_tshark_path(Settings.CAPTURE_TSHARK_PATH)
tshark_path = get_tshark_path(Settings.CAPTURE_TSHARK_PATH)
if Settings.CAPTURE_TSHARK_PATH is None:
Settings.CAPTURE_TSHARK_PATH = tshark_path
Settings.reconstruct_settings()
break
except TSharkNotFoundException:
errorlevel = show_error__tshark_not_detected()
Expand All @@ -2071,7 +2076,9 @@ def check_packages_version(third_party_packages: dict[str, str]):
if errorlevel == MsgBox.ReturnValues.IDABORT:
terminate_script("EXIT")
elif errorlevel == MsgBox.ReturnValues.IDIGNORE:
TSHARK_PATH = invalid_tshark_version.path
if Settings.CAPTURE_TSHARK_PATH is None:
Settings.CAPTURE_TSHARK_PATH = invalid_tshark_version.path
Settings.reconstruct_settings()
break

cls()
Expand Down Expand Up @@ -2405,7 +2412,7 @@ def check_packages_version(third_party_packages: dict[str, str]):
interface = Settings.CAPTURE_INTERFACE_NAME,
capture_filter = CAPTURE_FILTER,
display_filter = DISPLAY_FILTER,
tshark_path = TSHARK_PATH
tshark_path = Settings.CAPTURE_TSHARK_PATH
)
except TSharkNotFoundException:
errorlevel = show_error__tshark_not_detected()
Expand Down
11 changes: 8 additions & 3 deletions Modules/capture/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def find_tshark_by_argument_path(possible_tshark_paths: list[Path]):
user_tshark_path = tshark_path / "tshark.exe"

if user_tshark_path:
possible_tshark_paths.insert(0, user_tshark_path)
if user_tshark_path not in possible_tshark_paths:
possible_tshark_paths.insert(0, user_tshark_path)

return possible_tshark_paths

Expand All @@ -62,7 +63,9 @@ def find_tshark_by_wireshark_common_installation_path(possible_tshark_paths: lis
continue

program_files = Path(env_path)
possible_tshark_paths.append(program_files / "Wireshark" / "tshark.exe")
possible_tshark_path = program_files / "Wireshark" / "tshark.exe"
if possible_tshark_path not in possible_tshark_paths:
possible_tshark_paths.append(possible_tshark_path)

return possible_tshark_paths

Expand Down Expand Up @@ -91,7 +94,9 @@ def find_tshark_by_wireshark_regedit_installation_paths(possible_tshark_paths: l
if not display_name.startswith("Wireshark"):
continue

possible_tshark_paths.append(Path(install_location) / "tshark.exe")
possible_tshark_path = Path(install_location) / "tshark.exe"
if possible_tshark_path not in possible_tshark_paths:
possible_tshark_paths.append(possible_tshark_path)
except FileNotFoundError:
# Skip keys without the required values
continue
Expand Down

0 comments on commit 185a3ba

Please sign in to comment.