def index(req): output = "<html><head><title>Glacier Tracker Status</title></head><body>" output += "<h1>Glacier Tracker Status</h1>\r\n" output += "<h2>Latest Data Summary</h2>\r\n" output += ("<p>As at %s UTC</p>" % datetime.datetime.utcnow()) output += ( "<table border><tr><th>Site</th><th>IMEI</th><th>Timestamp</th>" + "<th>Longitude</th><th>Latitude</th><th>Altitude</th><th>Quality</th>" + "<th>HDOP</th><th>Satellites</th><th>Temperature</th><th>Position Count</th><th>View</th></tr>" ) DB = gpsdb.GpsDb(CONFIG) LATEST = DB.get_latest_data() for SITE in LATEST: COUNT = DB.get_data_count(SITE[1]) output += "<tr>" output += ("<td>%s</td>" % SITE[0]) output += ("<td><a href = \"data.py?imei=%s\">%s</a></td>" % (SITE[1], SITE[1])) output += ("<td>%s</td>" % SITE[2]) output += ("<td>%s</td>" % SITE[3]) output += ("<td>%s</td>" % SITE[4]) output += ("<td><a href = \"plotAltitude.py?imei=%s\">%s</a></td>" % (SITE[1], SITE[5])) output += ("<td>%s</td>" % SITE[6]) output += ("<td>%s</td>" % SITE[7]) output += ("<td><a href = \"plotSats.py?imei=%s\">%s</a></td>" % (SITE[1], SITE[8])) output += ( "<td><a href = \"http://data.glacsweb.info/iceland/tracker/plotTemperature?imei=%s\">%s</a></td>" % (SITE[1], SITE[9])) output += ("<td>%s</td>" % COUNT) output += ("<td>") output += ( "<a target=\"_blank\" href=\"https://maps.google.com/?q=%s,%s\">Map</a> " % (SITE[4], SITE[3])) output += ( "<a target=\"_blank\" href=\"https://maps.google.com/?t=k&q=%s,%s\">Satellite</a> " % (SITE[4], SITE[3])) output += ( "<a target=\"_blank\"href=\"http://data.glacsweb.info/iceland/tracker/plot.py?imei=%s\">Plot</a> " % SITE[1]) output += ( "<a target=\"_blank\"href=\"http://data.glacsweb.info/iceland/tracker/plotDistance.py?imei=%s\">Dist</a> " % SITE[1]) output += ( "<a target=\"_blank\"href=\"http://data.glacsweb.info/iceland/tracker/data.py?imei=%s\">Data</a> " % SITE[1]) output += "</td>" output += "</tr>" output += "</table>" output += "<p>Number of unprocessed messages: <a href=\"http://data.glacsweb.info/iridium\" target=\"_blank\">%d</a></p>\r\n" % DB.get_unprocessed_message_count( ) output += "<a href = \"data.py\"> Download data</a>" output += "</body></html>" return output
def index(req): output = "" DB = gpsdb.GpsDb(CONFIG) parameters = util.FieldStorage(req, keep_blank_values=1) if not "imei" in parameters.keys(): output += "Glacier,IMEI,timestamp,longitude,latitude,altitude,quality,hdop,sats\r\n" output += csv_convert(DB.get_data()) else: output += csv_convert( add_dist_vel(DB.get_data_imei(parameters.getfirst("imei")))) req.content_type = 'text/csvi' req.headers_out.add("Content-Disposition", "attachment;filename=tracker.csv") return output
def index(req): output = "" DB = gpsdb.GpsDb(CONFIG) parameters = util.FieldStorage(req, keep_blank_values=1) if not "imei" in parameters.keys(): output = "IMEI MUST BE SPECIFIED" else: output = """<html> <head> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([['timestamp','distance'],""" data = add_dist_vel(DB.get_data_imei(parameters.getfirst("imei"))) print data for line in data: output += '[ new Date(' + str(int(line[2].strftime("%s")) * 1000) + '),' + str(line[15]) + '],' # chop off final comma output = output[:-1] output += """]); var options = {""" output += "title: 'Iceland Glacier tracker Distance plot %s '," % parameters.getfirst( "imei") output += """ width: 1500, height: 1000, haxis: {title: 'timestamp'}, vaxis: {title: 'distance moved/m'}, legend: 'none', explorer: {} }; var chart = new google.visualization.LineChart(document.getElementById('chart_div')); chart.draw(data, options); } </script> </head> <body> <div id="chart_div" style="width: 1600px; height: 1000px;"></div> </body> </html>""" req.content_type = 'text/html' return output
def index(req): output = "" DB = gpsdb.GpsDb(CONFIG) parameters = util.FieldStorage(req, keep_blank_values=1) if not "imei" in parameters.keys(): output += "Glacier,IMEI,timestamp,longitude,latitude,altitude,quality,hdop,sats\r\n" output += csv_convert(DB.get_data()) else: output = """<html> <head> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([['lon','lat'],""" data = DB.get_data_imei(parameters.getfirst("imei")) for line in data: output += '[' + str(line[3]) + ',' + str(line[4]) + '],' # chop off final comma output = output[:-1] output += """]); var options = { title: 'Iceland Glacier tracker plot', width: 1500, height: 1000, haxis: {title: 'lon'}, vaxis: {title: 'lat'}, legend: 'none', explorer: {} }; var chart = new google.visualization.ScatterChart(document.getElementById('chart_div')); chart.draw(data, options); } </script> </head> <body> <div id="chart_div" style="width: 1600px; height: 1000px;"></div> </body> </html>""" req.content_type = 'text/html' return output