planteg
Posts: 13
Joined: Tue Apr 26, 2016 10:04 pm

Managing WiFi programatically

Mon May 08, 2017 9:15 pm

Hi fellows,

I am looking for a way to manage the 'wlan0' connection from within a Python program. I need to present a list of networks available, have the user pick a network and type the key. So I looked for a Python library, and found... only one. The library is wifi (information at https://wifi.readthedocs.io/en/latest/scanning.html. Things is it's not maintained anymore but since it's the only one -as far as I can tell - I gave it a try.

The issue I have is that

Code: Select all

list(Cell.all('wlan0'))
sometimes returns only on entry, the network I am connected to, and some other times all (?) the networks around me. Strangely,

Code: Select all

iwlist scan
at the command prompt always return more than one entry. So my trust in wifi is not high.

Does someone know another Python library for that purpose ?

I am afraid I will have to edit the wpa_supplicant.conf file, something I'd rather not do.

Thanks


planteg
Posts: 13
Joined: Tue Apr 26, 2016 10:04 pm

Re: Managing WiFi programatically

Tue May 09, 2017 7:44 pm

Thanks HCAB,

I haven't found that one. My issue is now solved. The code has to run under root (sudo puthon3 program.py does it). If not under root, the the only listed network should be the one you are connected to. I still try with WiFi, but will give python-wifi a try if I get blocked. python-wifi is 2 years old, I don't know if it's still maintained.

Looks like python manages wifi is not very hot.

Return to “Python”