Browse Source

correctly parsed xml data to html output + web autorefresh

pull/3/head
psy 11 years ago
parent
commit
ef1d3346ee
  1. 3
      main.py
  2. 30
      web/index.py

3
main.py

@ -276,6 +276,7 @@ class bc(object):
logfile.write(item) logfile.write(item)
print '='*45 + "\n" + "Packages Route:\n" + '='*45 print '='*45 + "\n" + "Packages Route:\n" + '='*45
for line in a.stdout: for line in a.stdout:
if self.options.debug == True:
logfile.write(line) logfile.write(line)
parts = line.split() parts = line.split()
for ip in parts: for ip in parts:
@ -393,7 +394,7 @@ class bc(object):
print(str(p.version)) print(str(p.version))
print('='*75) print('='*75)
# root checker # root checker
#root = self.try_running(self.check_root, "\nInternal error checking root permissions.") root = self.try_running(self.check_root, "\nInternal error checking root permissions.")
# extract browser type and path # extract browser type and path
browser = self.try_running(self.check_browser, "\nInternal error checking browser files path.") browser = self.try_running(self.check_browser, "\nInternal error checking browser files path.")
# extract url # extract url

30
web/index.py

@ -5,6 +5,7 @@ BC (Border-Check) is a tool to retrieve info of traceroute tests over website na
GPLv3 - 2013 by psy (epsylon@riseup.net) GPLv3 - 2013 by psy (epsylon@riseup.net)
""" """
from xml.dom.minidom import parseString from xml.dom.minidom import parseString
# extract data from a xml file # extract data from a xml file
file = open('data.xml','r') file = open('data.xml','r')
data = file.read() data = file.read()
@ -21,6 +22,24 @@ xmlCountry = dom.getElementsByTagName('country')[0].toxml()
xmlServerName = dom.getElementsByTagName('server_name')[0].toxml() xmlServerName = dom.getElementsByTagName('server_name')[0].toxml()
xmlMeta = dom.getElementsByTagName('meta')[0].toxml() xmlMeta = dom.getElementsByTagName('meta')[0].toxml()
# parse XML inputs
xmlLongitude = xmlLongitude.replace('<longitude>','')
xmlLatitude = xmlLatitude.replace('<latitude>','')
xmlLongitude = xmlLongitude.replace('</longitude>','')
xmlLatitude = xmlLatitude.replace('</latitude>','')
xmlMeta = xmlMeta.replace('<meta>','')
xmlMeta = xmlMeta.replace('</meta>','')
xmlHost = xmlHost.replace('<host>','')
xmlHost = xmlHost.replace('</host>','')
xmlIP = xmlIP.replace('<ip>','')
xmlIP = xmlIP.replace('</ip>','')
xmlCity = xmlCity.replace('<city>','')
xmlCity = xmlCity.replace('</city>','')
xmlCountry = xmlCountry.replace('<country>','')
xmlCountry = xmlCountry.replace('</country>','')
xmlServerName = xmlServerName.replace('<server_name>','')
xmlServerName = xmlServerName.replace('</server_name>','')
output = """ output = """
<html> <html>
<head> <head>
@ -28,6 +47,8 @@ output = """
<link rel="stylesheet" href="js/leaflet/leaflet.css" /> <link rel="stylesheet" href="js/leaflet/leaflet.css" />
<link rel="stylesheet" href="style.css" /> <link rel="stylesheet" href="style.css" />
<script src="js/leaflet/leaflet.js"></script> <script src="js/leaflet/leaflet.js"></script>
<!--<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>-->
<meta http-equiv="refresh" content="5">
</head> </head>
<body> <body>
<center> <center>
@ -35,18 +56,13 @@ output = """
<tr> <tr>
<td><center><div id="map" style="width: 600px; height: 400px"></div></center></td> <td><center><div id="map" style="width: 600px; height: 400px"></div></center></td>
<script> <script>
var map = L.map('map').setView(["""+xmlLongitude+""", """+xmlLatitude+"""], 14); var map = L.map('map').setView(["""+xmlLatitude+""", """+xmlLongitude+"""], 14);
L.tileLayer('Border Check', {
maxZoom: 18,
attribution: 'Map: <a href="http://openstreetmap.org">OpenStreetMap</a>'
}).addTo(map);
L.marker(["""+xmlLongitude+""", """+xmlLatitude+"""]).addTo(map) L.marker(["""+xmlLatitude+""", """+xmlLongitude+"""]).addTo(map)
.bindPopup("<b>"""+xmlMeta+"""</b><br />").openPopup(); .bindPopup("<b>"""+xmlMeta+"""</b><br />").openPopup();
var popup = L.popup(); var popup = L.popup();
</script> </script>
<br />
</tr> </tr>
<tr> <tr>
<td> <td>

Loading…
Cancel
Save