in tools/create_bazel_hashdict.py [0:0]
def get_hash_map(f):
"""Construct the hash map reading the release website, writing it to f."""
splitted_version = FLAGS.minimum_version.split(".")
if len(splitted_version) != 3:
sys.stderr.write(("Invalid version '%s', "
"expected a dot-separated version with 3 components "
"(e.g. 3.1.2)") % FLAGS.minimum_version)
sys.exit(-1)
version = [
int(splitted_version[0]),
int(splitted_version[1]),
int(splitted_version[2])
]
while True:
try:
v = "%s.%s.%s" % (version[0], version[1], version[2])
print("Getting SHA-256 for version " + v)
# Force 404 before we actually add the information
urllib2.urlopen(_URL_EXISTS.format(version = v)).read()
f.write(" \"%s\": {\n" % v)
for platform in FLAGS.platforms:
r = urllib2.urlopen(
_URL_FORMAT.format(version = v, platform = platform))
f.write(" \"%s\": \"%s\",\n" % (platform,
r.read().split(" ", 1)[0]))
f.write(" },\n")
version[2] += 1
except urllib2.HTTPError as e:
if e.code == 404:
print(" ==> Not a Bazel version")
# Current version does not exists, increase the lowest non null version number
if skipped_version(version):
version[2] += 1
elif version[2] == 0:
if version[1] == 0:
return
version[1] = 0
version[0] += 1
else:
version[2] = 0
version[1] += 1
else:
raise e