commit 805ba635a32ef6533523de6e77066ec8d0334105 Author: Arturo Filastò art@fuffa.org Date: Wed May 8 18:55:31 2013 +0200
Remove unused geodata module that depended on pygeoip --- ooni/nettest.py | 5 +++-- ooni/reporter.py | 2 +- ooni/utils/geodata.py | 40 ---------------------------------------- 3 files changed, 4 insertions(+), 43 deletions(-)
diff --git a/ooni/nettest.py b/ooni/nettest.py index 50c0cf0..f31488e 100644 --- a/ooni/nettest.py +++ b/ooni/nettest.py @@ -7,7 +7,8 @@ from twisted.python import usage, reflect
from ooni import geoip from ooni.tasks import Measurement -from ooni.utils import log, checkForRoot, geodata +from ooni.utils import log, checkForRoot +from ooni import geoip from ooni import config from ooni import otime
@@ -40,7 +41,7 @@ class NetTestLoader(object): config.privacy.includecity): log.msg("We will include some geo data in the report") try: - client_geodata = geodata.IPToLocation(config.probe_ip.address) + client_geodata = geoip.IPToLocation(config.probe_ip.address) except e.GeoIPDataFilesNotFound: log.err("Unable to find the geoip data files") client_geodata = {'city': None, 'countrycode': None, 'asn': None} diff --git a/ooni/reporter.py b/ooni/reporter.py index 05d59d6..85df36e 100644 --- a/ooni/reporter.py +++ b/ooni/reporter.py @@ -29,7 +29,7 @@ except ImportError: from ooni import errors
from ooni import otime -from ooni.utils import geodata, pushFilenameStack +from ooni.utils import pushFilenameStack from ooni.utils.net import BodyReceiver, StringProducer, userAgents
from ooni import config diff --git a/ooni/utils/geodata.py b/ooni/utils/geodata.py deleted file mode 100644 index 2acfdb0..0000000 --- a/ooni/utils/geodata.py +++ /dev/null @@ -1,40 +0,0 @@ -import re -import os - -from twisted.web.client import Agent -from twisted.internet import reactor, defer, protocol - -from ooni.utils import log, net -from ooni import config -from ooni.errors import GeoIPDataFilesNotFound - -try: - import pygeoip -except ImportError: - log.err("Unable to import pygeoip. We will not be able to run geo IP related measurements") - -def IPToLocation(ipaddr): - log.debug("looking up %s" % ipaddr) - city_file = os.path.join(config.advanced.geoip_data_dir, 'GeoLiteCity.dat') - country_file = os.path.join(config.advanced.geoip_data_dir, 'GeoIP.dat') - asn_file = os.path.join(config.advanced.geoip_data_dir, 'GeoIPASNum.dat') - - location = {'city': None, 'countrycode': None, 'asn': None} - try: - city_dat = pygeoip.GeoIP(city_file) - location['city'] = city_dat.record_by_addr(ipaddr)['city'] - - country_dat = pygeoip.GeoIP(country_file) - location['countrycode'] = country_dat.country_code_by_addr(ipaddr) - - asn_dat = pygeoip.GeoIP(asn_file) - asn = asn_dat.org_by_addr(ipaddr) - location['asn'] = re.search('AS\d+', asn).group(0) - - except IOError: - log.err("Could not find GeoIP data files. Go into data/ " - "and run make geoip") - raise GeoIPDataFilesNotFound - - return location -
tor-commits@lists.torproject.org