movestuff
This commit is contained in:
parent
07af40215b
commit
f1a34e3fcd
35 changed files with 22 additions and 18 deletions
|
@ -7,22 +7,22 @@ from StringIO import StringIO
|
|||
|
||||
|
||||
# load region database
|
||||
with open("./plugins/data/geoip_regions.json", "rb") as f:
|
||||
with open("./data/geoip_regions.json", "rb") as f:
|
||||
regions = json.loads(f.read())
|
||||
|
||||
if os.path.isfile(os.path.abspath("./plugins/data/GeoLiteCity.dat")):
|
||||
if os.path.isfile(os.path.abspath("./data/GeoLiteCity.dat")):
|
||||
# initalise geolocation database
|
||||
geo = pygeoip.GeoIP(os.path.abspath("./plugins/data/GeoLiteCity.dat"))
|
||||
geo = pygeoip.GeoIP(os.path.abspath("./data/GeoLiteCity.dat"))
|
||||
else:
|
||||
download = http.get("http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz")
|
||||
string_io = StringIO(download)
|
||||
geoip_file = gzip.GzipFile(fileobj=string_io, mode='rb')
|
||||
|
||||
output = open(os.path.abspath("./plugins/data/GeoLiteCity.dat"), 'wb')
|
||||
output = open(os.path.abspath("./data/GeoLiteCity.dat"), 'wb')
|
||||
output.write(geoip_file.read())
|
||||
output.close()
|
||||
|
||||
geo = pygeoip.GeoIP(os.path.abspath("./plugins/data/GeoLiteCity.dat"))
|
||||
geo = pygeoip.GeoIP(os.path.abspath("./data/GeoLiteCity.dat"))
|
||||
|
||||
|
||||
@hook.command
|
||||
|
|
Reference in a new issue