Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/geoip/files/update.py

Issue 29783590: #11294 - Include GeoIP2 downloads with geoip module (Closed)
Patch Set: Created May 16, 2018, 11:47 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld