This repository has been archived by the owner on Jun 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: Move snippet code These aren't true tests and shouldn't be labeled as such. * test: Add wireless scanning snippets * fix: Scan for wireless networks via CoreWLAN Fix #37 * style: Fix typos * fix: Use the scan results No need to retrieve from the cache.
- Loading branch information
1 parent
99191a5
commit ce8bd9b
Showing
11 changed files
with
81 additions
and
19 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/python | ||
import objc | ||
|
||
bundle_path = '/System/Library/Frameworks/CoreWLAN.framework' | ||
objc.loadBundle('CoreWLAN', | ||
bundle_path=bundle_path, | ||
module_globals=globals()) | ||
|
||
|
||
def wireless_scan(): | ||
"""Scan available wireless networks. | ||
Returns: | ||
Sorted array of dictionaries with rssi, bssid, and ssid_str from | ||
strongest rssi value to weakest. | ||
""" | ||
iface = CWInterface.interface() | ||
results, error = iface.scanForNetworksWithName_includeHidden_error_( | ||
None, True, None) | ||
if error: | ||
return error | ||
values = [] | ||
for i in results: | ||
if i.ssid() is None: | ||
continue | ||
wifi_stats = {'RSSI': i.rssiValue(), | ||
'BSSID': i.bssid(), | ||
'SSID_STR': i.ssid() | ||
} | ||
values.append(wifi_stats) | ||
return sorted(values, key=lambda k: k['RSSI'], reverse=True) | ||
|
||
|
||
print wireless_scan() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/python | ||
import subprocess | ||
import plistlib | ||
|
||
|
||
def wireless_scan(): | ||
"""Scan available wireless networks. | ||
Returns: | ||
Sorted array of dictionaries with rssi, bssid, and ssid_str from | ||
strongest rssi value to weakest. | ||
""" | ||
ssid_scan = subprocess.check_output( | ||
['/System/Library/PrivateFrameworks/' | ||
'Apple80211.framework/Versions/A/' | ||
'Resources/airport', '-s', '--xml'] | ||
) | ||
ssid_scan = plistlib.readPlistFromString(ssid_scan) | ||
values = [] | ||
for i, val in enumerate(ssid_scan): | ||
wifi_stats = {'RSSI': val.get('RSSI'), | ||
'BSSID': val.get('BSSID'), | ||
'SSID_STR': val.get('SSID_STR') | ||
} | ||
values.append(wifi_stats) | ||
return sorted(values, key=lambda k: k['RSSI'], reverse=True) | ||
|
||
|
||
print wireless_scan() |
File renamed without changes.
File renamed without changes.
Empty file modified
0
pkgroot/Library/Application Support/pinpoint/bin/FoundationPlist/FoundationPlist.py
100644 → 100755
Empty file.
Empty file modified
0
pkgroot/Library/Application Support/pinpoint/bin/FoundationPlist/__init__.py
100644 → 100755
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters