Skip to main content

A python library to control wpa_supplicant via it's control socket.

Project description

https://coveralls.io/repos/github/smartfile/pywpas/badge.svg?branch=master https://github.com/btimby/pywpas/actions/workflows/ci.yml/badge.svg https://badge.fury.io/py/pywpas.svg

pywpas

A python library to control wpa_supplicant via it’s control socket.

Installation

pip install pywpas

Example:

import time
import pywpas
# sock_path below is the default and can be omitted.
ctrl = pywpas.Control(sock_path='/var/run/wpa_supplicant)

# You can get a list of interface names:
interface_names = ctrl.interface_names()
print(interface_names)

# You can iterate over instances of the Interface class:
for interface in ctrl.interfaces:
    print(interface.name)

# You can get a specific Interface instance by name:
interface = ctrl.interface(interface_names[0])
print(interface.status())

# You can scan for networks available on an interface:
interface.scan()
# You might wait a few seconds...
time.sleep(5.0)
scan_results = interface.results()

for network in scan_results:
    print(network.ssid, network.signal_level)

# You can connect to a network:
interface.connect(scan_results[0])
interface.disconnect()

# You can define a network and connect to it:
network = pywpas.Network(ssid='FOOBAR', ...)
interface.connect(network)
interface.disconnect()

# There is a high-level scan function, it will invoke callback
# with each unique network found during the scan timeout duration:
pywpas.scan(interface, lambda network: print(network.ssid), timeout=30.0)

wpa_supplicant

You must configure wpa_supplicant to open a control socket. Optionally you can enable config file writing.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=nobody
update_config=1

Development

To deploy to PyPI:

git tag <version>
git push --tags

CI will do the rest.

Tests and linting:

make test
make lint

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywpas-0.9.0.tar.gz (10.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page