2013-07-16 11:28:28 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# This script simply downloads waf to the current directory
|
|
|
|
|
|
|
|
from __future__ import print_function
|
2013-11-24 21:01:03 +00:00
|
|
|
import os, sys, stat, hashlib, subprocess
|
|
|
|
|
2014-03-04 11:08:40 +00:00
|
|
|
WAFRELEASE = "waf-1.7.15"
|
2013-11-24 21:01:03 +00:00
|
|
|
WAFURL = "https://waf.googlecode.com/files/" + WAFRELEASE
|
2014-03-04 11:08:40 +00:00
|
|
|
SHA256HASH = "e5ae7028f9b2d8ce1acb9fe1092e8010a90ba764d3ac065ea4e846743290b1d6"
|
2013-07-16 11:28:28 +00:00
|
|
|
|
2013-11-24 16:00:12 +00:00
|
|
|
if os.path.exists("waf"):
|
2013-11-26 20:34:02 +00:00
|
|
|
wafver = subprocess.check_output(['./waf', '--version']).decode()
|
|
|
|
if WAFRELEASE.split('-')[1] == wafver.split(' ')[1]:
|
|
|
|
print("Found 'waf', skipping download.")
|
|
|
|
sys.exit(0)
|
2013-11-24 16:00:12 +00:00
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
try:
|
|
|
|
from urllib.request import urlopen
|
|
|
|
except:
|
|
|
|
from urllib2 import urlopen
|
|
|
|
|
2013-11-24 16:00:12 +00:00
|
|
|
print("Downloading %s..." % WAFURL)
|
|
|
|
waf = urlopen(WAFURL).read()
|
2013-07-16 11:28:28 +00:00
|
|
|
|
|
|
|
if SHA256HASH == hashlib.sha256(waf).hexdigest():
|
|
|
|
with open("waf", "wb") as wf:
|
|
|
|
wf.write(waf)
|
|
|
|
|
|
|
|
os.chmod("waf", os.stat("waf").st_mode | stat.S_IXUSR)
|
|
|
|
print("Checksum verified.")
|
|
|
|
else:
|
|
|
|
print("The checksum of the downloaded file does not match!")
|
|
|
|
print("Please download and verify the file manually.")
|
|
|
|
|
|
|
|
sys.exit(1)
|