Skip to content

Instantly share code, notes, and snippets.

@acidprime
Created December 28, 2011 22:55
Show Gist options
  • Save acidprime/1530248 to your computer and use it in GitHub Desktop.
Save acidprime/1530248 to your computer and use it in GitHub Desktop.
Some Python Airport code
#!/usr/bin/python -tt
import subprocess
airport = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport'
def getAirportInfo():
arguments = [airport,"--getinfo"]
execute = subprocess.Popen(arguments, stdout=subprocess.PIPE)
out, err = execute.communicate()
dict = {}
for line in out.split('\n'):
parse = line.split(': ')
try:
key = parse[0].strip()
value = parse[1]
dict[key] = value
except IndexError:
None
return dict
airportInfo = getAirportInfo()
print airportInfo['SSID']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment