[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Do not fail if probes IP addres is not known data is not available.
commit 39e613a7fbb2877d1f805b0289c757320643deca
Author: Arturo Filastò <art@xxxxxxxxx>
Date: Sat Dec 8 19:56:23 2012 +0100
Do not fail if probes IP addres is not known data is not available.
---
ooni/reporter.py | 14 +++++++++-----
ooni/utils/geodata.py | 1 +
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/ooni/reporter.py b/ooni/reporter.py
index e14f64d..b5de29f 100644
--- a/ooni/reporter.py
+++ b/ooni/reporter.py
@@ -112,10 +112,10 @@ def getTestDetails(options):
from ooni import __version__ as software_version
client_geodata = {}
- if config.privacy.includeip or \
+ if config.probe_ip and (config.privacy.includeip or \
config.privacy.includeasn or \
config.privacy.includecountry or \
- config.privacy.includecity:
+ config.privacy.includecity):
log.msg("We will include some geo data in the report")
client_geodata = geodata.IPToLocation(config.probe_ip)
@@ -128,16 +128,20 @@ def getTestDetails(options):
# has been specified
if client_geodata and not config.privacy.includeasn:
client_geodata['asn'] = 'AS0'
- else:
+ elif 'asn' in client_geodata:
# XXX this regexp should probably go inside of geodata
client_geodata['asn'] = \
re.search('AS\d+', client_geodata['asn']).group(0)
log.msg("Your AS number is: %s" % client_geodata['asn'])
+ else:
+ client_geodata['asn'] = None
- if client_geodata and not config.privacy.includecity:
+ if (client_geodata and not config.privacy.includecity) \
+ or ('city' not in client_geodata):
client_geodata['city'] = None
- if client_geodata and not config.privacy.includecountry:
+ if (client_geodata and not config.privacy.includecountry) \
+ or ('countrycode' not in client_geodata):
client_geodata['countrycode'] = None
test_details = {'start_time': otime.utcTimeNow(),
diff --git a/ooni/utils/geodata.py b/ooni/utils/geodata.py
index 5cad748..d9883ba 100644
--- a/ooni/utils/geodata.py
+++ b/ooni/utils/geodata.py
@@ -30,6 +30,7 @@ def IPToLocation(ipaddr):
asn_dat = pygeoip.GeoIP(asn_file)
location['asn'] = asn_dat.org_by_addr(ipaddr)
+
except IOError:
log.err("Could not find GeoIP data files. Go into data/ "
"and run make geoip")
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits