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
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.1.tar.gz
(97.1 kB
view details)
File details
Details for the file Cpywpa-1.0.1.tar.gz.
File metadata
- Download URL: Cpywpa-1.0.1.tar.gz
- Upload date:
- Size: 97.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be3e2a7d7ff275c41c2d22bb7d5503993bdfdde50bd0103a6d3dc48a01d123f2
|
|
| MD5 |
8087b0ab5783fd54af09b619db3c1f78
|
|
| BLAKE2b-256 |
48e1fd11edfbb56cd77d435bad82a9d10e66d48694f4511bc56c856ff733bf7c
|