[mirrorbrain-commits] [opensuse-svn] r7674 - trunk/tools/download-redirector-v2/mirrordoctor/mb

From: Novell Forge SVN <noreply_at_novell.com>
Date: Fri, 3 Jul 2009 06:01:21 -0600 (MDT)
Author: poeml
Date: 2009-07-03 06:01:17 -0600 (Fri, 03 Jul 2009)
New Revision: 7674

Modified:
   trunk/tools/download-redirector-v2/mirrordoctor/mb/geoip.py
Log:
mb new:
- try different geoip database locations (GeoIP database was moved around...).
  prefer the larger city lite database, if available, and prefer updated copies
  that were fetched with the geoip-lite-update tool.


Modified: trunk/tools/download-redirector-v2/mirrordoctor/mb/geoip.py
===================================================================
--- trunk/tools/download-redirector-v2/mirrordoctor/mb/geoip.py	2009-07-03 10:25:45 UTC (rev 7673)
+++ trunk/tools/download-redirector-v2/mirrordoctor/mb/geoip.py	2009-07-03 12:01:17 UTC (rev 7674)
@@ -1,15 +1,30 @@
+import os
 from subprocess import Popen, PIPE
 
+# try different databases and different locations
+databases = ['/var/lib/GeoIP/GeoLiteCity.dat.updated', 
+             '/var/lib/GeoIP/GeoLiteCity.dat', 
+             '/var/lib/GeoIP/GeoIP.dat.updated',
+             '/var/lib/GeoIP/GeoIP.dat',
+             '/usr/share/GeoIP/GeoLiteCity.dat.updated', 
+             '/usr/share/GeoIP/GeoLiteCity.dat', 
+             '/usr/share/GeoIP/GeoIP.dat.updated',
+             '/usr/share/GeoIP/GeoIP.dat',
+             ]
+for i in databases:
+    if os.path.exists(i):
+        database = i
 
+
 def lookup_country_code(addr):
-    out = Popen(['geoiplookup', addr], stdout=PIPE).communicate()[0]
+    out = Popen(['geoiplookup', '-f', database, addr], stdout=PIPE).communicate()[0]
     out = out.split(':')[1].strip().split(',')[0]
 
     return out.lower()
 
 
 def lookup_region_code(addr):
-    out = Popen(['geoiplookup_continent', addr], stdout=PIPE).communicate()[0]
+    out = Popen(['geoiplookup_continent', '-f', database, addr], stdout=PIPE).communicate()[0]
 
     return out.strip().lower()
 

_______________________________________________
Opensuse-svn mailing list
Opensuse-svn_at_forge.novell.com
http://forge.novell.com/mailman/listinfo/opensuse-svn


_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on 2009-07-03Z12:01:35

This archive was generated by hypermail 2.2.0 : 2009-07-10Z19:18:14 GMT