bear-tools 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bear_tools-0.2.1 → bear_tools-0.2.2}/PKG-INFO +1 -1
- {bear_tools-0.2.1 → bear_tools-0.2.2}/pyproject.toml +1 -1
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/macos_utils.py +42 -2
- {bear_tools-0.2.1 → bear_tools-0.2.2}/LICENSE +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/README.md +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/__init__.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/cereal/__init__.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/cereal/client.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/cereal/mods/__init__.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/cereal/mods/base.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/cereal/serial_manager.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/cereal/server.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/cereal/tokenizer.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/dict_utils.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/enhanced_enum.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/enhanced_int_enum.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/example_protocol.yaml +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/fsm/README.md +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/fsm/__init__.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/fsm/fsm.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/linting_utils.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/lumberjack/README.md +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/lumberjack/__init__.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/lumberjack/callback_config.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/lumberjack/color.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/lumberjack/log_level.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/lumberjack/logger.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/markdown_utils.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/misc_utils.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/network_utils.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/os_utils.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/publisher/__init__.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/publisher/listener.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/publisher/publisher.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/py.typed +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/spreadsheet_utils.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/string_utils.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/thread_utils.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/time_utils.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/transport_protocol.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/type_defs.py +0 -0
- {bear_tools-0.2.1 → bear_tools-0.2.2}/src/bear_tools/yaml_utils.py +0 -0
|
@@ -70,6 +70,46 @@ def get_current_ssid() -> str | None:
|
|
|
70
70
|
return get_current_ssid_macos15()
|
|
71
71
|
|
|
72
72
|
|
|
73
|
+
def get_ssid_for_interface(interface: str) -> str | None:
|
|
74
|
+
"""
|
|
75
|
+
Get the SSID currently joined on a specific Wi-Fi interface
|
|
76
|
+
|
|
77
|
+
:param interface: The wireless interface to query (e.g. 'en0', 'en1')
|
|
78
|
+
:return: The SSID joined on `interface` if any; None otherwise
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
macos_version: str = platform.mac_ver()[0]
|
|
82
|
+
if macos_version.startswith('14'):
|
|
83
|
+
return get_current_ssid_macos14_and_older(interface=interface)
|
|
84
|
+
return get_current_ssid_macos15(interface=interface)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def get_local_ip_for_ssid(ssid: str, max_interface_index: int = 9) -> str | None:
|
|
88
|
+
"""
|
|
89
|
+
Find this Mac's local IPv4 address on the NIC currently joined to a given SSID
|
|
90
|
+
|
|
91
|
+
Iterates `en0` through `en<max_interface_index>` looking for an interface that reports the
|
|
92
|
+
requested SSID via `networksetup -getairportnetwork` (or its macOS 15+ equivalent), then
|
|
93
|
+
returns the IPv4 address bound to that interface via `ipconfig getifaddr`.
|
|
94
|
+
|
|
95
|
+
:param ssid: The SSID to match against
|
|
96
|
+
:param max_interface_index: Highest `en<N>` index to probe (default 9)
|
|
97
|
+
:return: The IPv4 address as a string if found; None otherwise
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
for index in range(max_interface_index + 1):
|
|
101
|
+
interface = f'en{index}'
|
|
102
|
+
if get_ssid_for_interface(interface) != ssid:
|
|
103
|
+
continue
|
|
104
|
+
try:
|
|
105
|
+
output: str = subprocess.check_output(['ipconfig', 'getifaddr', interface]).decode().strip()
|
|
106
|
+
except subprocess.CalledProcessError:
|
|
107
|
+
continue
|
|
108
|
+
if output:
|
|
109
|
+
return output
|
|
110
|
+
return None
|
|
111
|
+
|
|
112
|
+
|
|
73
113
|
if __name__ == '__main__':
|
|
74
|
-
|
|
75
|
-
print(f'ssid: "{
|
|
114
|
+
_ssid: str | None = get_current_ssid()
|
|
115
|
+
print(f'ssid: "{_ssid}"')
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|