Detect corrupt downloads
This commit is contained in:
3
build.py
3
build.py
@@ -62,6 +62,7 @@ SRC = [path
|
|||||||
if path.endswith('.js')]
|
if path.endswith('.js')]
|
||||||
|
|
||||||
PLOVR_JAR = 'bin/plovr-eba786b34df9.jar'
|
PLOVR_JAR = 'bin/plovr-eba786b34df9.jar'
|
||||||
|
PLOVR_JAR_MD5 = '20eac8ccc4578676511cf7ccbfc65100'
|
||||||
|
|
||||||
|
|
||||||
def report_sizes(t):
|
def report_sizes(t):
|
||||||
@@ -205,7 +206,7 @@ pake.virtual('plovr', PLOVR_JAR)
|
|||||||
|
|
||||||
@pake.target(PLOVR_JAR, clean=False)
|
@pake.target(PLOVR_JAR, clean=False)
|
||||||
def plovr_jar(t):
|
def plovr_jar(t):
|
||||||
t.download('https://plovr.googlecode.com/files/' + os.path.basename(PLOVR_JAR))
|
t.download('https://plovr.googlecode.com/files/' + os.path.basename(PLOVR_JAR), md5=PLOVR_JAR_MD5)
|
||||||
|
|
||||||
|
|
||||||
@pake.target('gh-pages', 'hostexamples', 'doc', phony=True)
|
@pake.target('gh-pages', 'hostexamples', 'doc', phony=True)
|
||||||
|
|||||||
7
pake.py
7
pake.py
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import collections
|
import collections
|
||||||
import contextlib
|
import contextlib
|
||||||
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
@@ -126,8 +127,12 @@ class Target(object):
|
|||||||
def debug(self, *args, **kwargs):
|
def debug(self, *args, **kwargs):
|
||||||
self.logger.debug(*args, **kwargs)
|
self.logger.debug(*args, **kwargs)
|
||||||
|
|
||||||
def download(self, url):
|
def download(self, url, md5=None):
|
||||||
content = urllib2.urlopen(url).read()
|
content = urllib2.urlopen(url).read()
|
||||||
|
if md5 and hashlib.md5(content).hexdigest() != md5:
|
||||||
|
raise pake.BuildError(t, 'corrupt download')
|
||||||
|
# FIXME Python on Windoze corrupts the content when writing it
|
||||||
|
# FIXME probably something to do with encodings
|
||||||
with open(self.name, 'w') as f:
|
with open(self.name, 'w') as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user