Python Forum

Full Version: Python module wifi not showing all wireless networks
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The call to wifi.Cell.all is not returning all wireless networks as regular user but is does as root user !
I don't know if it is a bug or by design. I don't know if it is related to the other network is a 5GHz or not.


Output:
upsscan@orangepi3:~/bin$ ls /sys/class/net eth0 lo wlan0 upsscan@orangepi3:~/bin$ python Python 2.7.16 (default, Oct 10 2019, 22:02:15) [GCC 8.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import wifi >>> wifi.Cell.all ('wlan0') [Cell(ssid=rozsasnet)] >>> upsscan@orangepi3:~/bin$ sudo python Python 2.7.16 (default, Oct 10 2019, 22:02:15) [GCC 8.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import wifi >>> wifi.Cell.all ('wlan0') [Cell(ssid=rozsasnet), Cell(ssid=rozsasnet_5G)] >>> upsscan@orangepi3:~/bin$
One of then is 2.4GHz and the other one is 5GHz.
Why wifi.Cell.all ('wlan0') is returning only one wifi network as regular user?
How can I get all wireless networks as a regular user ?
According to docs:
Quote:To get a list of the different cells in the area, you can do

>>> from wifi import Cell, Scheme
>>> Cell.all('wlan0')
This returns a list of Cell objects. Under the hood, this calls iwlist scan and parses the unfriendly output.
# Here I skip some of the docs, not relevant, and there is the Note

Note
Scanning requires root permission to see all the networks. If you are not root, iwlist only returns the network you are currently connected to.
(Jan-24-2020, 01:55 PM)buran Wrote: [ -> ]Note
Scanning requires root permission to see all the networks. If you are not root, iwlist only returns the network you are currently connected to.
Thank you ! Somehow I misssed the note, my bad.

What are my alternatives ? What is the best approach to get this information ? What are other options than create a script that does the "iwlist wlan0 scan", then put that script in /etc/sudoers and call it from my python program with subprocess ?
Do you know a less "dirty" option ?
I have no idea about the alternatives, maybe someone else...