Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wifi module. #244

Merged
merged 5 commits into from
Apr 3, 2017
Merged
Show file tree
Hide file tree
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
15 changes: 10 additions & 5 deletions examples/camera/basic/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'''
Basic camera example
Default picture is saved as /sdcard/org.test.cameraexample/enter_file_name_here.jpg
Default picture is saved as
/sdcard/org.test.cameraexample/enter_file_name_here.jpg
'''

from os import getcwd
Expand All @@ -18,10 +19,11 @@

from plyer import camera


class CameraDemo(FloatLayout):
def __init__(self):
super(CameraDemo, self).__init__()
self.cwd = getcwd() + "/"
self.cwd = getcwd() + "/"
self.ids.path_label.text = self.cwd

def do_capture(self):
Expand All @@ -34,10 +36,11 @@ def do_capture(self):
return False

try:
camera.take_picture(filename=filepath,
camera.take_picture(filename=filepath,
on_complete=self.camera_callback)
except NotImplementedError:
popup = MsgPopup(msg="This feature has not yet been implemented for this platform.")
msg = "This feature has not yet been implemented for this platform."
popup = MsgPopup(msg=msg)
popup.open()

def camera_callback(self, filepath):
Expand All @@ -48,6 +51,7 @@ def camera_callback(self, filepath):
popup = MsgPopup(msg="Could not save your picture!")
popup.open()


class CameraDemoApp(App):
def __init__(self):
super(CameraDemoApp, self).__init__()
Expand All @@ -63,11 +67,12 @@ def on_pause(self):
def on_resume(self):
pass


class MsgPopup(Popup):
def __init__(self, msg):
super(MsgPopup, self).__init__()
self.ids.message_label.text = msg


if __name__ == '__main__':
CameraDemoApp().run()

7 changes: 6 additions & 1 deletion plyer/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'''

__all__ = ('PY2', 'string_types', 'queue', 'iterkeys',
'itervalues', 'iteritems')
'itervalues', 'iteritems', 'xrange')

import sys
try:
Expand Down Expand Up @@ -32,3 +32,8 @@
iterkeys = lambda d: iter(d.keys())
itervalues = lambda d: iter(d.values())
iteritems = lambda d: iter(d.items())

if PY2:
xrange = xrange
else:
xrange = range
8 changes: 4 additions & 4 deletions plyer/facades/wifi.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def start_scanning(self):
'''
Turn on scanning.
'''
self._start_scanning()
return self._start_scanning()

def get_network_info(self, name):
'''
Expand All @@ -88,19 +88,19 @@ def get_available_wifi(self):
'''
Returns a list of all the available wifi.
'''
self._get_available_wifi()
return self._get_available_wifi()

def connect(self, network, parameters):
'''
Method to connect to some network.
'''
self._connect(network=network, parameters=parameters)
return self._connect(network=network, parameters=parameters)

def disconnect(self):
'''
To disconnect from some network.
'''
self._disconnect()
return self._disconnect()

# private

Expand Down
3 changes: 2 additions & 1 deletion plyer/platforms/win/libs/wifi_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from ctypes import *
from ctypes.wintypes import *
from sys import exit
from plyer.compat import xrange


def customresize(array, new_size):
Expand Down Expand Up @@ -447,7 +448,7 @@ def _make_dict():
global _dict
_dict = {}
for network in available:
_dict[str(network.dot11Ssid.SSID)] = network
_dict[network.dot11Ssid.SSID] = network


def _get_available_wifi():
Expand Down