Skip to content

Commit c1c5dda

Browse files
📝 Add docstrings to drop_gui
Docstrings generation was requested by @JarbasAl. * #39 (comment) The following files were modified: * `ovos_PHAL_plugin_network_manager/__init__.py`
1 parent 8887209 commit c1c5dda

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

ovos_PHAL_plugin_network_manager/__init__.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ovos_config import Configuration
66
from ovos_plugin_manager.templates.phal import AdminPlugin, AdminValidator, PHALPlugin, PHALValidator
77
from ovos_utils.log import LOG
8-
from ovos_PHAL_plugin_network_manager.gui import GUISetup
8+
99

1010
# Event Documentation
1111
# ===================
@@ -77,6 +77,15 @@ class NetworkManagerPlugin(PHALPlugin):
7777
validator = NetworkManagerValidator
7878

7979
def __init__(self, bus=None, config=None):
80+
"""
81+
Initialize the NetworkManagerPlugin and register PHAL network event handlers on the message bus.
82+
83+
Registers handlers for network manager events such as scanning, connecting (including open networks), reconnecting, disconnecting, forgetting networks, and querying the currently connected network.
84+
85+
Parameters:
86+
bus: Message bus instance used to subscribe to PHAL events.
87+
config: Optional configuration dictionary or object for plugin initialization.
88+
"""
8089
super().__init__(bus=bus, name="ovos-PHAL-plugin-network-manager", config=config)
8190
# Register Network Manager Events
8291
self.bus.on("ovos.phal.nm.scan", self.handle_network_scan_request)
@@ -86,11 +95,20 @@ def __init__(self, bus=None, config=None):
8695
self.bus.on("ovos.phal.nm.disconnect", self.handle_network_disconnect_request)
8796
self.bus.on("ovos.phal.nm.forget", self.handle_network_forget_request)
8897
self.bus.on("ovos.phal.nm.get.connected", self.handle_network_connected_query)
89-
self.gui_setup = GUISetup(bus=bus) # extra GUI events
9098

9199
# Network Manager Events
92100
def handle_network_scan_request(self, message):
93101
# Scan for networks using Network Manager and build a list of networks found and their security types
102+
"""
103+
Scan for available Wi-Fi networks using Network Manager and emit a completion message with results.
104+
105+
Performs an nmcli rescan and lists SSID and SECURITY fields, then emits an "ovos.phal.nm.scan.complete" Message on the bus with a payload containing a "networks" list. Each list item is a dict with keys:
106+
- "ssid": network SSID string
107+
- "security": security string reported by nmcli
108+
109+
Parameters:
110+
message (Message): Incoming request message (contents are not inspected).
111+
"""
94112
LOG.info("Scanning for networks using nmcli backend")
95113
subprocess.Popen(
96114
['nmcli', 'dev', 'wifi', 'rescan']

0 commit comments

Comments
 (0)