Python Forum
Python module wifi not showing all wireless networks
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python module wifi not showing all wireless networks
#1
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 ?
Reply
#2
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(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 ?
Reply
#4
I have no idea about the alternatives, maybe someone else...
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Check Interenet connection type: 4G or WiFi Pavel_47 1 1,901 Jan-02-2022, 06:45 PM
Last Post: ndc85430
  scapy wifi scan to get payload \ data korenron 0 2,109 Nov-16-2021, 01:47 PM
Last Post: korenron
  raspberry pi - connection - wireless - tkinter Nick_tkinter 2 2,558 Feb-22-2021, 04:11 PM
Last Post: Nick_tkinter
  Acces Wifi router and scan all the available networks through router jenkins43 3 2,722 Mar-21-2020, 09:35 PM
Last Post: jenkins43

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020