00001
00002
00003 import sys
00004 import netifaces
00005
00006 for inf in netifaces.interfaces():
00007 if inf.startswith('wlan'):
00008 addrs = netifaces.ifaddresses(inf)
00009 if not netifaces.AF_INET in addrs:
00010 continue
00011 else:
00012 print addrs[netifaces.AF_INET][0]['addr']
00013 break
00014 else:
00015 print >> sys.stderr, "failed to determine IP address"
00016 print "127.0.0.1"
00017 sys.exit(1)