def main(): try: plfile = open(pl_filename, 'r') except: print "[ERROR]: planet lab list not found. \n" return for line in plfile: try: ip = socket.gethostbyname(line.rstrip()) city, latitude, longtitude = ip_db_lookup(ip) print line.rstrip(), ip, latitude, longtitude, city except: pass
print '<?xml version="1.0" encoding="UTF-8"?>' print '<kml xmlns="http://earth.google.com/kml/2.2">' print ' <Document>' print ' <Folder>' for key in exit_points: name, dst_ip = key n, asn, ip = exit_points[key][0] # print '%d, ' % n, print "<Placemark>", print "<name>%s</name>" % name city1, lat1, lon1 = ip_db_lookup(dst_ip) # print '%s, %s, %s, %s, ' % (dst_ip, city1, lat1, lon1), city2, lat2, lon2 = ip_db_lookup(ip) # print '%s, %s, %s, %s' % (ip, city2, lat2, lon2) print '<LineString><coordinates>' print lon1, ',', lat1, ', 0' print lon2, ',', lat2, ', 0' print "</coordinates></LineString>" print "</Placemark>" print ' </Folder>' print ' </Document>' print '</kml>' # 70.42.185.10 San Francisco 37.7697 -122.3933 208.175.172.10 Chesterfield 38.65 -90.5334