Skip to content

Commit

Permalink
fix kivy#230
Browse files Browse the repository at this point in the history
  • Loading branch information
kiok46 committed Sep 14, 2016
1 parent 88ffc95 commit cc460f1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 0 additions & 2 deletions examples/wifi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ def start_wifi(self):
wifi_button = self.ids['wifi_button']
wifi_button.text = 'Showing Scan Results'
wifi_button.on_release = self.show_wifi_scans
if not self.is_enabled():
wifi.enable()
wifi.start_scanning()
stop_wifi_button = self.ids['stop_wifi_button']
stop_wifi_button.disabled = False
Expand Down
26 changes: 15 additions & 11 deletions plyer/platforms/linux/wifi.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
from plyer.facades import Wifi
from subprocess import Popen, PIPE, call, STDOUT

try:
import wifi
except ImportError:
sys.stderr.write("python-wifi not installed. try:"
"`sudo pip install wifi`.")
return Wifi()


class LinuxWifi(Wifi):
names = {}

def _is_enabled():
def _is_enabled(self):
'''
TODO: Implement this in future.
Returns `True` if wifi is enabled else `False`.
'''
return
enbl = Popen(["nmcli", "radio", "wifi"], stdout=PIPE, stderr=PIPE)
if enbl.communicate()[0].split()[0] == "enabled":
return True
return False

def _start_scanning(self):
'''
Expand Down Expand Up @@ -75,4 +71,12 @@ def _disconnect(self):


def instance():
return LinuxWifi()
import sys
try:
import wifi
return LinuxWifi()
except ImportError:
sys.stderr.write("python-wifi not installed. try:"
"`sudo pip install wifi`.")

return Wifi()

0 comments on commit cc460f1

Please sign in to comment.