all: reformat python files with python black
Part of !537. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/537
This commit is contained in:

committed by
Thomas Haller

parent
b6febb0fd0
commit
be822b52e6
@@ -14,7 +14,9 @@ import dbus
|
||||
bus = dbus.SystemBus()
|
||||
|
||||
# Get a proxy for the base NetworkManager object
|
||||
proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager")
|
||||
proxy = bus.get_object(
|
||||
"org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager"
|
||||
)
|
||||
manager = dbus.Interface(proxy, "org.freedesktop.NetworkManager")
|
||||
|
||||
all_aps = []
|
||||
@@ -35,20 +37,26 @@ for d in devices:
|
||||
# Get device's type; we only want wifi devices
|
||||
iface = prop_iface.Get("org.freedesktop.NetworkManager.Device", "Interface")
|
||||
dtype = prop_iface.Get("org.freedesktop.NetworkManager.Device", "DeviceType")
|
||||
if dtype == 2: # WiFi
|
||||
if dtype == 2: # WiFi
|
||||
# Get a proxy for the wifi interface
|
||||
wifi_iface = dbus.Interface(dev_proxy, "org.freedesktop.NetworkManager.Device.Wireless")
|
||||
wifi_iface = dbus.Interface(
|
||||
dev_proxy, "org.freedesktop.NetworkManager.Device.Wireless"
|
||||
)
|
||||
wifi_prop_iface = dbus.Interface(dev_proxy, "org.freedesktop.DBus.Properties")
|
||||
|
||||
# Get the associated AP's object path
|
||||
connected_path = wifi_prop_iface.Get("org.freedesktop.NetworkManager.Device.Wireless", "ActiveAccessPoint")
|
||||
connected_path = wifi_prop_iface.Get(
|
||||
"org.freedesktop.NetworkManager.Device.Wireless", "ActiveAccessPoint"
|
||||
)
|
||||
|
||||
# Get all APs the card can see
|
||||
aps = wifi_iface.GetAccessPoints()
|
||||
for path in aps:
|
||||
ap_proxy = bus.get_object("org.freedesktop.NetworkManager", path)
|
||||
ap_prop_iface = dbus.Interface(ap_proxy, "org.freedesktop.DBus.Properties")
|
||||
bssid = ap_prop_iface.Get("org.freedesktop.NetworkManager.AccessPoint", "HwAddress")
|
||||
bssid = ap_prop_iface.Get(
|
||||
"org.freedesktop.NetworkManager.AccessPoint", "HwAddress"
|
||||
)
|
||||
|
||||
# Cache the BSSID
|
||||
if not bssid in all_aps:
|
||||
@@ -62,4 +70,3 @@ for d in devices:
|
||||
print("\nFound APs:")
|
||||
for bssid in all_aps:
|
||||
print(bssid)
|
||||
|
||||
|
Reference in New Issue
Block a user