Cpywpa is another simple tools to control wpa_supplicant. It use Cython to interact with OFFICIAL C interface
Project description
Cpywpa
Introduction
Cpywpa is another simple tool to control wpa_supplicant for Python. However, rather than using d-Bus, it wrote with Cython so it can directly use OFFICIAL C interface.
Installation
First, make sure you have the latest pip
python3 -m pip install --upgrade pip
Then you can install Cpywpa with this command
python3 -m pip install Cpywpa
Here is the dependent packages and they will be installed during installation.
package name | version |
---|---|
setuptools | None |
wheel | None |
Cython | None |
How to use
⚠ NOTE ⚠
While only root user can access wpa_supplicant interface, all codes below are running with sudo or by root user.
- Get current network status
from Cpywpa import NetworkManager
from pprint import pprint
manager = NetworkManager()
pprint(manager.getStatus())
- List known network
from Cpywpa import NetworkManager
from pprint import pprint
manager = NetworkManager()
pprint(manager.listNetwork())
- Scan network around and get scan results
from Cpywpa import NetworkManager
from pprint import pprint
from time import sleep
manager = NetworkManager()
# you can use scan() to scan and get scan results
# use scan_time to set sleep time
pprint(manager.scan(scan_time=8))
# or use onlyScan() to scan and use scanResults() to get results
manager.onlyScan()
sleep(10)
pprint(manager.scanResults())
- Connect to a network
from Cpywpa import NetworkManager
manager = NetworkManager()
# connect to a known network
# Syize is my wifi name
manager.connect('Syize')
# connect to a new network
manager.connect('Syize', passwd='wifi-password')
- Add a network but don't connect
from Cpywpa import NetworkManager
manager = NetworkManager()
manager.addNetwork('Syize', 'wifi-password')
- Delete a network
from Cpywpa import NetworkManager
manager = NetworkManager()
manager.removeNetwork('Syize')
For more information, please head to GitHub
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Cpywpa-1.0.tar.gz
(96.9 kB
view hashes)