[cig-commits] r15745 - cs/plot-user-map/trunk
leif at geodynamics.org
leif at geodynamics.org
Mon Oct 5 12:31:03 PDT 2009
Author: leif
Date: 2009-10-05 12:31:03 -0700 (Mon, 05 Oct 2009)
New Revision: 15745
Modified:
cs/plot-user-map/trunk/plot-user-map.py
Log:
Call gethostbyname() on log file entries and report any errors.
Modified: cs/plot-user-map/trunk/plot-user-map.py
===================================================================
--- cs/plot-user-map/trunk/plot-user-map.py 2009-10-05 19:06:34 UTC (rev 15744)
+++ cs/plot-user-map/trunk/plot-user-map.py 2009-10-05 19:31:03 UTC (rev 15745)
@@ -281,12 +281,34 @@
print '<hr/>'
+ from socket import gethostbyname
ipList = []
+ errors = []
for pathname in fileList:
s = open(pathname, 'r')
for line in s:
- ipList.append(line.strip())
+ entry = line.strip()
+ try:
+ entry = gethostbyname(entry)
+ except Exception, error:
+ errors.append((entry, str(error)))
+ continue
+ ipList.append(entry)
+ if errors:
+ print '<h2>Errors<h2>'
+ print '<table>'
+ print '<tr>'
+ for th in ['entry', 'error']:
+ print '<th>%s</th>' % th
+ print '</tr>'
+ for error in errors:
+ print '<tr>'
+ for td in error:
+ print '<td>%s</td>' % td
+ print '</tr>'
+ print '</table>'
+
table = queryDatabase(ipList)
latLonList = []
More information about the CIG-COMMITS
mailing list