OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 import urllib | 3 import urllib |
4 import zlib | 4 import zlib |
5 | 5 |
6 downloads = { | 6 downloads = { |
7 '/usr/share/GeoIP/GeoIP.dat': 'http://geolite.maxmind.com/download/geoip/dat
abase/GeoLiteCountry/GeoIP.dat.gz', | 7 '/usr/share/GeoIP/GeoIP.dat': 'http://geolite.maxmind.com/download/geoip/dat
abase/GeoLiteCountry/GeoIP.dat.gz', |
8 '/usr/share/GeoIP/GeoIPv6.dat': 'http://geolite.maxmind.com/download/geoip/d
atabase/GeoIPv6.dat.gz', | 8 '/usr/share/GeoIP/GeoIPv6.dat': 'http://geolite.maxmind.com/download/geoip/d
atabase/GeoIPv6.dat.gz', |
9 | 9 |
10 '/usr/share/GeoIP/GeoIPCity.dat': 'http://geolite.maxmind.com/download/geoip
/database/GeoLiteCity.dat.gz', | 10 '/usr/share/GeoIP/GeoIPCity.dat': 'http://geolite.maxmind.com/download/geoip
/database/GeoLiteCity.dat.gz', |
11 '/usr/share/GeoIP/GeoIPCityv6.dat': 'http://geolite.maxmind.com/download/geo
ip/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz', | 11 '/usr/share/GeoIP/GeoIPCityv6.dat': 'http://geolite.maxmind.com/download/geo
ip/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz', |
| 12 |
| 13 '/usr/share/GeoIP/GeoIP2.dat': 'http://geolite.maxmind.com/download/geoip/da
tabase/GeoLite2-Country.tar.gz', |
| 14 '/usr/share/GeoIP/GeoIP2City.dat': 'http://geolite.maxmind.com/download/geoi
p/database/GeoLite2-City.tar.gz', |
12 } | 15 } |
13 | 16 |
14 for dest, source in downloads.iteritems(): | 17 for dest, source in downloads.iteritems(): |
15 data = urllib.urlopen(source).read() | 18 data = urllib.urlopen(source).read() |
16 with open(dest, "wb") as f: | 19 with open(dest, "wb") as f: |
17 # wbit parameter value isn't properly documented, see https://stackoverf
low.com/a/22310760/785541 | 20 # wbit parameter value isn't properly documented, see https://stackoverf
low.com/a/22310760/785541 |
18 f.write(zlib.decompress(data, zlib.MAX_WBITS | 16)) | 21 f.write(zlib.decompress(data, zlib.MAX_WBITS | 16)) |
OLD | NEW |