Welcome to PyWiFi Controls’s documentation!

PyWiFi - Connection Control

Module that controls Wi-Fi connect or disconnect.

class pywifi.control_connection.ControlConnection(wifi_ssid: str = None, wifi_password: str = None, logger: Logger = None)

Wrapper for Wi-Fi connection.

>>> ControlConnection

Instantiates the object.

Parameters:
  • wifi_ssid – SSID of the Wi-Fi connection.

  • wifi_password – Password for the Wi-Fi connection.

  • logger – Bring your own logger.

darwin_connector() bool

Connects to Wi-Fi using SSID and password in env vars for macOS.

linux_connector() bool

Connects to Wi-Fi using SSID and password in env vars for Linux.

win_connector() bool

Connects to Wi-Fi using SSID and password in env vars for Windows.

win_create_new_connection() bool

Establish a new connection using a xml config for Windows.

wifi_connector() bool

Connects to the Wi-Fi SSID stored in env vars (OS-agnostic).

PyWiFi - Peripheral Control

Module that controls toggling Wi-Fi on or off.

pywifi.control_peripheral.get_connection_info(logger: Logger, target: str = 'SSID') Optional[str]

Gets information about the network connected.

Returns:

Wi-Fi or Ethernet SSID or Name.

Return type:

str

class pywifi.control_peripheral.ControlPeripheral(name: str = None, logger: Logger = None)

Initiates ControlPeripheral to toggle Wi-Fi on or off.

>>> ControlPeripheral

Instantiates the object.

Parameters:
  • name – Takes the name of the peripheral connection.

  • logger – Bring your own logger.

darwin_enable() None

Enables Wi-Fi on macOS.

darwin_disable() None

Disables Wi-Fi on macOS.

linux_enable() None

Enables Wi-Fi on Linux.

linux_disable() None

Disables Wi-Fi on Linux.

win_enable() None

Enables Wi-Fi on Windows.

win_disable() None

Disables Wi-Fi on Windows.

enable() None

Enable Wi-Fi (OS-agnostic).

disable() None

Disable Wi-Fi (OS-agnostic).

Module

pywifi.model.process_err(error: Union[CalledProcessError, SubprocessError], logger: Logger) str

Logs errors along with return code and output based on type of error.

Parameters:
  • error – Takes any one of multiple subprocess errors as argument.

  • logger – Logger object.

Returns:

Decoded version of the error message or an empty string.

Return type:

str

class pywifi.model.Commands

Wrapper for OS specific commands.

>>> Commands
nmcli: str = '/usr/bin/nmcli'
networksetup: str = '/usr/sbin/networksetup'
netsh: str = 'C:\\Windows\\System32\\netsh.exe'
pywifi.model.get_env(key: str, default: Any = None, alias: str = None)

Get environment variable (case insensitive) with default and alias options.

Parameters:
  • key – Key of the enviornment variable.

  • default – Default value in case key is not found in env var. Defaults to None.

  • alias – Alias key. Defaults to None.

See also

Order of execution:
  1. key

  2. alias

  3. default

class pywifi.model.Settings

Wrapper for settings.

>>> Settings
root_pass: str = None
wifi_ssid: str = None
wifi_password: str = None
nmcli: str = None
netsh: str = None
networksetup: str = None

Indices and tables