forked from 0x2620/pandora
add manage command to update geoip db
This commit is contained in:
parent
c8da81ceb6
commit
5a79659bb3
2 changed files with 27 additions and 9 deletions
|
@ -116,20 +116,23 @@ def update_static():
|
|||
image = os.path.join(settings.STATIC_ROOT, 'png/logo%d.png'%size)
|
||||
if not os.path.exists(image):
|
||||
shutil.copyfile(pandora, image)
|
||||
|
||||
#download geo data
|
||||
path = os.path.join(settings.GEOIP_PATH, 'GeoLiteCity.dat')
|
||||
if not os.path.exists(path):
|
||||
url = 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz'
|
||||
print 'download', url
|
||||
ox.net.saveUrl(url, "%s.gz"%path)
|
||||
os.system('gunzip "%s.gz"' % path)
|
||||
|
||||
update_geoip()
|
||||
#poster script
|
||||
if not os.path.exists(settings.ITEM_POSTER):
|
||||
os.symlink(settings.ITEM_POSTER.replace('poster', 'oxdb_poster'),
|
||||
settings.ITEM_POSTER)
|
||||
|
||||
|
||||
def update_geoip(force=False):
|
||||
path = os.path.join(settings.GEOIP_PATH, 'GeoLiteCity.dat')
|
||||
if not os.path.exists(path) or force:
|
||||
url = 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz'
|
||||
print 'download', url
|
||||
ox.net.saveUrl(url, "%s.gz"%path)
|
||||
if os.path.exists(path):
|
||||
os.unlink(path)
|
||||
os.system('gunzip "%s.gz"' % path)
|
||||
|
||||
def init():
|
||||
load_config()
|
||||
thread.start_new_thread(reloader_thread, ())
|
||||
|
|
15
pandora/app/management/commands/update_geoip.py
Normal file
15
pandora/app/management/commands/update_geoip.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from ... import config
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""
|
||||
"""
|
||||
help = 'update geoip database'
|
||||
args = ''
|
||||
|
||||
def handle(self, **options):
|
||||
config.update_geoip(True)
|
Loading…
Reference in a new issue