This returns a list of>>> from wifi import Cell, Scheme
Cellobjects. Under the hood, this calls iwlist scan and parses the unfriendly output.
Each cell object should have the following attributes:
For cells that have
encryptedas True, there will also be the following attributes:
Scanning requires root permission to see all the networks. If you are not root, iwlist only returns the network you are currently connected to.
Connecting to a networkIn order to connect to a network, you need to set up a scheme for it.
Once you have a scheme saved, you can retrieve it using
>>> cell = Cell.all('wlan0')
>>> scheme = Scheme.for_cell('wlan0', 'home', cell, passkey)
>>> scheme = Scheme.find('wlan0', 'home')
NoteActivating a scheme will disconnect from any other scheme before connecting.
You must be root to connect to a network. Wifi uses ifdown and ifup to connect and disconnect.
- Presents a Python interface to the output of iwlist.
- Returns a list of all cells extracted from the output of iwlist.
- Parses the output of iwlist scan for one cell and returns a Cell object for it.
- Runs a filter over the output of
all()and the returns a list of cells that match that filter.
Scheme(interface, name, options=None)
- Saved configuration for connecting to a wireless network. This class provides a Python interface to the /etc/network/interfaces file.
- Connects to the network as configured in this scheme.
- Returns an generator of saved schemes.
- Deletes the configuration from the
- Returns a
Schemeor None based on interface and name.
for_cell(interface, name, cell, passkey=None)
- Intuits the configuration needed for a specific
Celland creates a
- A class factory for providing a nice way to specify the interfaces file that you want to use. Use this instead of directly overwriting the interfaces Class attribute if you care about thread safety.
- Writes the configuration to the
interfacesfile.you can download