Skip to main content

Network Changer

Some python3.7+ utilities for changing the network you’re computer is on

With super thanks to @igo95862 for the sdbus library I use after https://github.com/igo95862/python-sdbus/issues/1

Installation

Something like:

> python3 -m venv network_changer
> ./network_changer/bin/python -m pip install network_changer
> ./network_changer/network_changer info

On Linux systems with nmcli it’ll install sdbus related dbus libraries. You can modify that behaviour with these environment variables at pip install:

NETWORK_CHANGER_NO_SDBUS

Don’t automatically install sdbus. If you want sdbus anyway then use:

> python -m pip instal network_changer[sdbus]

On linux systems without nmcli, you’ll need libiw-dev to be installed for network switching to work. You will also need sudo for all actions with iw and for wpasupplicant to be uninstalled.

If you are using nmcli on a raspberry Pi, you’ll need to do the following:

> sudo apt-get install network-manager
# Make /etc/NetworkManager/NetworkManager.conf look like this
|   [main]
|   plugins=ifupdown,keyfile
|   dhcp=internal
|
|   [ifupdown]
|   managed=true
# Make sure /etc/dhcpcd.conf has "denyinterfaces wlan0" in it somewhere
> sudo reboot

On a Mac, it’ll shell out to the airport CLI command. Note that the only thing that requires sudo is disconnection.

There is no Windows support.

Usage

Once you’ve installed network_manager you have three commands available to you:

network_manager info

Display the bssid and ssid of the interface

--interface <iface>

Specify which interface to use. By default it’ll find the one most appropriate for your system. So en0 on Mac and wlan0 on a linux

network_manager scan

Display the bssid and ssid of the access points the interface can see

--interface <iface>

Specify which interface to use. By default it’ll find the one most appropriate for your system. So en0 on Mac and wlan0 on a linux

--filter-bssid <some string>

Only show networks whose bssid contains the specified string in it

--filter-ssid <some string>

Only show networks whose ssid contains the specified string in it

network_manager connect

Connect to the network with the specified ssid. Note that this library does not support networks that have any type of security.

--interface <iface>

Specify which interface to use. By default it’ll find the one most appropriate for your system. So en0 on Mac and wlan0 on a linux

--ssid <ssid>

The ssid to connect to

Changelog

0.1.0 - TBD
  • Initial release

  • Note that there are no unit tests and this code isn’t actively used by me

Metadata

Release files for network-changer 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for network-changer 0.1.0
File Size Uploaded
network-changer-0.1.0.tar.gz 22.3 kB Details

Release files / network-changer-0.1.0.tar.gz

Download URL network-changer-0.1.0.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
846d730652fea9dc773da8f69ed989001cd3032f7abed065aa706d2f98af7351
BLAKE2b-256 checksum
How to use checksums
aa57de33b88864df1cde8ae1833517dcf3f6571297ce9b8c9f4285cbe15ce4fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.13

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page