[Python / OSX]Get network connection details, restart wifi, and do more than you think straight from python

Hi!
I recently figured out how to restart internet(en0) interface on OSX and read some interesting details about our connection. Thanks to objc library I was able to access objective-C methods provided by OSX.
Here is CWInterface Class Reference. Check it out because this documentation provide many interesting methods.

Continue reading [Python / OSX]Get network connection details, restart wifi, and do more than you think straight from python

[Python]How to scan for available networks on OSX

Hi!
I’m posting this simple code for getting list of avaliable networks on OSX.


#!/usr/bin/python
import os

f = os.popen('airport -s')
now = f.read().splitlines(True)
database=[]
for x in range(1,len(now)):
	i = now[x].strip().index(':')
	ssid_database=now[x].strip()
	#print(ssid_database)
	database.append(ssid_database[0:i-3])
print(database)

Try that with
python filename.py

Have fun! 🙂