Closed wgaylord closed 7 years ago
Did you try running pywifi in python3 env? Because I wrote pywifi in python3 env, I am not quite sure it can run on python2 env now
Well.. I was using py2
I'm mostly use py2 because that's what most people use. (Like even most professionals use it over py3)
On Oct 6, 2016 11:13 AM, "Awk" notifications@github.com wrote:
Did you try running pywifi in python3 env? Because I wrote pywifi in python3 env, I am not quite sure it can run on python2 env now
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/awkman/pywifi/issues/8#issuecomment-252011706, or mute the thread https://github.com/notifications/unsubscribe-auth/ACCNyfWJaY1xZ7547kLSrGcXC-LDyMWNks5qxR42gaJpZM4KOTdo .
Any idea if this can be looked into?
After I fix issue #10, I will try to test pywifi under py2.7 and evaluate is it possible to support py2.7. I am not quite sure about how many py3 features now pywifi depends on...
I think what needs to be considered is the way python 2.7 handles imports compared to python 3.X as well as some syntax changes. Might not even be worth going to 2.7 as the differences between the two are quite large.
Heres a handy little article: http://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html
So should I just continue searching for a py2.7 compatible wifi lib and just close this? Because I need to stay on 2.7 (I have many reasons)
Up to awkman I suppose, whats your aim with the use of this lib?
@chibill I'm currently working on a project which uses the win32api. There might be a few issues with syntax but have a read: https://github.com/thepizzagui/wifiSwap/blob/master/wlanAPI.py
Well I am mostly interested in being able to get the wifi BSSID around me. So I can make a script to auto connect to some APs. (Like the free ones at McDonalds.)
Im working on something similar as a small project. At its current version the code I linked is quite messy however it gets bssids and ssids and stores then in a dict for easy access. Probably works for 2.7
I can make the current version ( Just now downloaded from repo) load and work by just changing the way that the metaclass is defined.. (Do it the python 2 why that is still correct for python 3).
And it appears to work. (Scan works and scan_results works. Still testing other stuff)
Okay the network_profiles works (Sort of one of the networks around me has a key type that errors it out. WPA2) I also know how to patch it so that status works (Python 2.7 ctypes.wintypes does not have PDWORD but if you copy the line that defines it from cytpes.wintypes on python 3 it works)
@chibill Good news!! Is it convenient for you to send a PR after you finish the modification and test under python 2.7? I would learn from the patch and try to merge it into pywifi!!
I can. Not sure about the strange stuff with WPA2 it seems odd. (But that exists in. Python3)
I mean the problem with that exists in py3 also
Could you share the error message?
I know why its erroring. https://github.com/awkman/pywifi/blob/master/pywifi/win/wifiutil.py#L43-L47 Does not contain a value with the key WPA2 (Which is the auth type my schools wifi uses when looking at the xml file)
`
<encryption>AES</encryption>
<useOneX>true</useOneX>
</authEncryption>`
Thats the area you use to find the auth type.
Which actually acording to windows its using WPA@-Enterprise for a Security type.
Actually Traceback is.
Traceback (most recent call last): File "
", line 1, in File "C:\Python27\lib\site-packages\pywifi\iface.py", line 82, in network_profiles profiles = self._wifi_ctrl.network_profiles(self._raw_obj) File "C:\Python27\lib\site-packages\pywifi\win\wifiutil.py", line 364, in network_profiles profile['key_mgmt'].append(key_mgmt_dict[key_mgmt]) KeyError: u'WPA2'
Oh... I don't start to plan to support other key mgmt type now. That's because I don't have the environment to test them. I think we should add one more key mgmt type like 'OTHER' to skip it.
True.. I wonder how you could handle them. (Why do you use a dict there anyways?)
Could we not just keep what ever was returned by the xml as a string? For both auth and also encryption?
I didn't consider other auth type at that moment, so I adopted dict here. I want a unified expression for key mgmt while getting the scan result or assigning the ap profile. So, I think keep them as integers is better.
Okay. Currently they are only used for network_profiles. And adapting them to use the string directly actually removes so if statements from the add_network_profile. (Would only need to check for if its open)
I will leave that alone as I am just interested in getting it python 2 compatible.
@chibill Thanks for your idea and PR, I merge your PR now.
Okay. So this can be closed now. :)
I am on Windows10 with python 2.7.12
`>>> wifi.interfaces()[0].scan()
is the error.