[tor-commits] [bridgedb/master] Move HTTPServer.geoipdb to _geoipdb and outside try function.

isis at torproject.org isis at torproject.org
Wed Mar 26 05:49:31 UTC 2014


commit e6e7552e8c8207ea04c42d209ec735a3c12b2238
Author: Isis Lovecruft <isis at torproject.org>
Date:   Mon Mar 17 22:53:30 2014 +0000

    Move HTTPServer.geoipdb to _geoipdb and outside try function.
    
     * If it's outside the try function, it's easier to change from other modules
       (as well as for unittests).
---
 lib/bridgedb/HTTPServer.py |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/bridgedb/HTTPServer.py b/lib/bridgedb/HTTPServer.py
index e9abc78..89989eb 100644
--- a/lib/bridgedb/HTTPServer.py
+++ b/lib/bridgedb/HTTPServer.py
@@ -59,19 +59,19 @@ lookup = TemplateLookup(directories=[template_root],
                         collection_size=500)
 
 
+_geoipdb = '/usr/share/GeoIP/GeoIP.dat'
+
 try:
     # Make sure we have the database before trying to import the module:
-    geoipdb = '/usr/share/GeoIP/GeoIP.dat'
-    if not os.path.isfile(geoipdb):
+    if not os.path.isfile(_geoipdb):
         raise EnvironmentError("Could not find %r. On Debian-based systems, "\
                                "please install the geoip-database package."
-                               % geoipdb)
+                               % _geoipdb)
     # This is a "pure" python version which interacts with the Maxmind GeoIP
     # API (version 1). It require, in Debian, the libgeoip-dev and
     # geoip-database packages.
     import pygeoip
-    geoip = pygeoip.GeoIP(geoipdb, flags=pygeoip.MEMORY_CACHE)
-
+    geoip = pygeoip.GeoIP(_geoipdb, flags=pygeoip.MEMORY_CACHE)
 except Exception as err:
     logging.debug("Error while loading geoip module: %r" % err)
     logging.warn("GeoIP database not found")





More information about the tor-commits mailing list