[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Add notice about using ooniresources to download geoip files.



commit ed7d57c4d71809eb3f27f9ae0fc6542700d3e565
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Tue Aug 12 21:55:02 2014 +0200

    Add notice about using ooniresources to download geoip files.
---
 ooni/geoip.py |   19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/ooni/geoip.py b/ooni/geoip.py
index 14dde4b..86383d0 100644
--- a/ooni/geoip.py
+++ b/ooni/geoip.py
@@ -34,29 +34,30 @@ def IPToLocation(ipaddr):
 
     location = {'city': None, 'countrycode': 'ZZ', 'asn': 'AS0'}
 
+    def error():
+        log.err("Could not find GeoIP data file in %s."
+                "Try running ooniresources --update-geoip or"
+                " edit your ooniprobe.conf" % config.advanced.geoip_data_dir)
+
     try:
         country_dat = GeoIP(country_file)
         location['countrycode'] = country_dat.country_code_by_addr(ipaddr)
         if not location['countrycode']:
             location['countrycode'] = 'ZZ'
     except IOError:
-        log.err("Could not find GeoIP data file. Go into %s "
-                "and make sure GeoIP.dat is present or change the location "
-                "in the config file" % config.advanced.geoip_data_dir)
+        error()
+
     try:
         city_dat = GeoIP(city_file)
         location['city'] = city_dat.record_by_addr(ipaddr)['city']
     except:
-         log.err("Could not find the city your IP is from. "
-                "Download the GeoLiteCity.dat file into the geoip_data_dir"
-                " or install geoip-database-contrib.")
+        error()
+
     try:
         asn_dat = GeoIP(asn_file)
         location['asn'] = asn_dat.org_by_addr(ipaddr).split(' ')[0]
     except:
-        log.err("Could not find the ASN for your IP. "
-                "Download the GeoIPASNum.dat file into the geoip_data_dir"
-                " or install geoip-database-contrib.")
+        error()
 
     return location
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits