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/datab
ase/GeoLiteCountry/GeoIP.dat.gz', | 7 '/usr/share/GeoIP/GeoIP.dat': 'http://geolite.maxmind.com/download/geoip/datab
ase/GeoLiteCountry/GeoIP.dat.gz', |
8 '/usr/share/GeoIP/GeoIPv6.dat': 'http://geolite.maxmind.com/download/geoip/dat
abase/GeoIPv6.dat.gz', | 8 '/usr/share/GeoIP/GeoIPv6.dat': 'http://geolite.maxmind.com/download/geoip/dat
abase/GeoIPv6.dat.gz', |
9 | 9 |
10 '/usr/share/GeoIP/GeoIPCity.dat': 'http://geolite.maxmind.com/download/geoip/d
atabase/GeoLiteCity.dat.gz', | 10 '/usr/share/GeoIP/GeoIPCity.dat': 'http://geolite.maxmind.com/download/geoip/d
atabase/GeoLiteCity.dat.gz', |
11 '/usr/share/GeoIP/GeoIPCityv6.dat': 'http://geolite.maxmind.com/download/geoip
/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz', | 11 '/usr/share/GeoIP/GeoIPCityv6.dat': 'http://geolite.maxmind.com/download/geoip
/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz', |
12 } | 12 } |
13 | 13 |
14 for dest, source in downloads.iteritems(): | 14 for dest, source in downloads.iteritems(): |
15 data = urllib.urlopen(source).read() | 15 data = urllib.urlopen(source).read() |
16 with open(dest, "wb") as f: | 16 with open(dest, "wb") as f: |
17 # wbit parameter value isn't properly documented, see https://stackoverflow.
com/a/22310760/785541 | 17 # wbit parameter value isn't properly documented, see https://stackoverflow.
com/a/22310760/785541 |
18 f.write(zlib.decompress(data, zlib.MAX_WBITS | 16)) | 18 f.write(zlib.decompress(data, zlib.MAX_WBITS | 16)) |
OLD | NEW |