Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Added disconnect support for nmcli interfaces. #33

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions wireless/Wireless.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ def power(self, power=None):
def driver(self):
return self._driver_name

def disconnect(self):
return self._driver.disconnect()


# abstract class for all wireless drivers
class WirelessDriver:
Expand All @@ -113,6 +116,9 @@ def interface(self, interface=None):
def power(self, power=None):
pass

@abstractmethod
def disconnect(self):
pass

# Linux nmcli Driver < 0.9.9.0
class NmcliWireless(WirelessDriver):
Expand Down Expand Up @@ -164,6 +170,10 @@ def connect(self, ssid, password):
# parse response
return not self._errorInResponse(response)

def disconnect(self):
response = cmd('nmcli dev disconnect iface {}'.format(self._interface))
return not self._errorInResponse(response)

# returned the ssid of the current network
def current(self):
# list active connections for all interfaces
Expand Down Expand Up @@ -249,6 +259,10 @@ def _errorInResponse(self, response):
# if we didn't find an error then we are in the clear
return False

def disconnect(self):
response = cmd('nmcli dev disconnect iface {}'.format(self._interface))
return not self._errorInResponse(response)

# connect to a network
def connect(self, ssid, password):
# clean up previous connection
Expand Down