Skip to main content

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.

  1. Get current network status
from Cpywpa import NetworkManager
from pprint import pprint

manager = NetworkManager()
pprint(manager.getStatus())
  1. List known network
from Cpywpa import NetworkManager
from pprint import pprint

manager = NetworkManager()
pprint(manager.listNetwork())
  1. 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())
  1. 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')
  1. Add a network but don't connect
from Cpywpa import NetworkManager

manager = NetworkManager()
manager.addNetwork('Syize', 'wifi-password')
  1. Delete a network
from Cpywpa import NetworkManager

manager = NetworkManager()
manager.removeNetwork('Syize')

For more information, please head to GitHub

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

Cpywpa-1.0.1.tar.gz (97.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