Changeset 11444 in genesis
- Timestamp:
- Sep 5, 2012, 9:06:53 PM (12 years ago)
- Location:
- tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gformat.py
r11427 r11444 1153 1153 content_type='application/vnd.google-earth.kml+xml' 1154 1154 output = make_network_kml.make_graph() 1155 elif base_uri.endswith('/api/get/nodeplanner.json'): 1156 content_type='application/json' 1157 output = make_network_kml.make_nodeplanner_json() 1155 1158 elif not uri[0]: 1156 1159 if is_text_request(environ): … … 1460 1463 for header in response_headers: 1461 1464 print "%s: %s" % header 1462 print "\n"1465 print 1463 1466 print output 1464 1467 -
tools/make_network_kml.py
r10890 r11444 6 6 import gformat 7 7 import glob 8 import json 8 9 import os 9 10 import re … … 71 72 ''' 72 73 73 def make_graph(debug=False):74 def get_graph_data(debug=False): 74 75 poel = {} 75 76 link_type = {} … … 140 141 if debug: print e 141 142 sys.exit(1) 142 143 return (poel, link_type, link_data, link_status, hosts) 144 145 146 def make_nodeplanner_json(debug=False): 147 # Input data 148 poel, link_type, link_data, link_status, hosts = get_graph_data(debug) 149 150 # Export data 151 points = [] 152 for nodename, datadump in hosts.iteritems(): 153 points.append({'name': datadump['nodename'], 'lat' : float(datadump['latitude']), 'lon' : float(datadump['longitude']), 'state' : datadump['status']}) 154 links = [] 155 for addr,leden in poel.iteritems(): 156 for index,lid in enumerate(leden[:-1]): 157 for buur in leden[index + 1:]: 158 links.append({'master' : hosts[buur]['nodename'], 'slave': hosts[lid]['nodename'], 'state' : link_status[addr][4:].lower()}) 159 160 # Format data 161 return json.dumps({'points' : points, 'links' : links}) 162 163 164 165 def make_graph(debug=False): 166 poel, link_type, link_data, link_status, hosts = get_graph_data(debug) 143 167 output = '' 144 168 if debug: print "# Building KML file"
Note:
See TracChangeset
for help on using the changeset viewer.