Changeset 157

Show
Ignore:
Timestamp:
03/03/10 16:23:57 (5 months ago)
Author:
mbooth
Message:

Add a button to show the raw data pretty-printed to help debugging.

Location:
trunk/misc
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/misc

    • Property svn:ignore set to
      .project
      .pydevproject
  • trunk/misc/dns-o-matic.py

    r156 r157  
    138138 
    139139    # iterate through all valid addresses in the subnet 
    140     for ip in [x for x in list(subnet) if x != subnet.broadcast and x != subnet.ip]: 
     140    sys.stderr.write("Subnet %s...\n" % str(subnet)); 
     141    for ip in [str(x) for x in list(subnet) if x != subnet.broadcast and x != subnet.ip]: 
    141142        sys.stderr.write("Processing %s\n" % ip); 
    142         address = {'ip':str(ip), 'results':[]} 
     143        address = {'ip':ip, 'results':[]} 
    143144        for ns,pri in nameservers: 
    144             RecursiveLookup(address,str(ip),'PTR',ns) 
     145            RecursiveLookup(address,ip,'PTR',ns) 
    145146 
    146147        # forget about addresses that don't have records in *any* nameservers 
     
    183184    heading = "<tr><th>address</th>" 
    184185    for ns in data['nameservers']: 
    185         heading += "<th>%s</th>" % ns['name'] 
     186        if ns['primary']: 
     187            heading += "<th>%s (SOA)</th>" % ns['name'] 
     188        else: 
     189            heading += "<th>%s</th>" % ns['name'] 
    186190    heading += "</tr>" 
    187191             
     
    199203    # for debugging 
    200204    import pprint 
    201     print "<!--" 
     205    print "<pre style='display:none;'>" 
    202206    pp = pprint.PrettyPrinter(indent=2) 
    203207    pp.pprint(data) 
    204     print "-->" 
     208    print "</pre>" 
    205209 
    206210 
     
    209213<head> 
    210214  <title>DNS-o-Matic Report</title> 
     215  <script type="text/javascript" src="jquery.js"></script> 
     216  <script type="text/javascript"> 
     217    jQuery(document).ready(function($) { 
     218      $("a#debugs_on").css('display', 'inline'); 
     219      $("a#debugs_on").click(function() { 
     220        $("pre").css('display', 'block'); 
     221        $("table").css('display', 'none'); 
     222        $("a#debugs_on").css('display', 'none'); 
     223        $("a#debugs_off").css('display', 'inline'); 
     224      }); 
     225      $("a#debugs_off").click(function() { 
     226        $("pre").css('display', 'none'); 
     227        $("table").css('display', 'block'); 
     228        $("a#debugs_on").css('display', 'inline'); 
     229        $("a#debugs_off").css('display', 'none'); 
     230      }); 
     231    }); 
     232  </script> 
    211233  <style> 
    212234    th { 
     
    240262<body> 
    241263<h1>DNS-o-Matic Report</h1> 
     264  <a id='debugs_on' href='#' style='display:none;'>Show Debugs</a> 
     265  <a id='debugs_off' href='#' style='display:none;'>Hide Debugs</a> 
    242266""" 
    243267