import dbus NM = 'org.freedesktop.NetworkManager' NMP = '/org/freedesktop/NetworkManager' NMI = NM + '.Device' PI = 'org.freedesktop.DBus.Properties' def list_ssids(): # get the base NetworkManager object and bind an interface to it bus = dbus.SystemBus() nm = bus.get_object(NM,NMP) nmi = dbus.Interface(nm,NM) # Iterate over the devices queried via the interface for dev in nmi.GetDevices(): # get each and bind a property interface to it devo = bus.get_object(NM,dev) devpi = dbus.Interface(devo,PI) # Single out the Wi-Fi ones if devpi.Get(NM,'DeviceType') == 2: wdevi = dbus.Interface(devo,NMI + '.Wireless') for ap in wdevi.GetAccessPoints(): apo = bus.get_object(NM,ap) api = dbus.Interface(apo,PI) # unpack the SSID string print ''.join(["%c" % b for b in api.Get(NMI,'Ssid')]) if __name__ == '__main__': list_ssids()