csvfile.close() print 'Making database...' makedb.readFile('ip-to-country.csv', isGeo) print '\nCleaning up...' os.remove('ip-to-country.csv.zip') os.remove('ip-to-country.csv') print '\nDone.\n' try: from ip2c.ip2country import ip2country ip2c = ip2country() working = True except IOError: working = False print 'IP2Country database initialization failed. Attempting to update.' try: update() from ip2c.ip2country import ip2country ip2c = ip2country() working = True except: print 'Update failed.' except ImportError: working = False print 'ip2c module not found. IP2Country lookups not available.' print 'run fetch_deps.py to fetch it'
def reloaddb(): if not working: return ip2c = ip2country()