Last active
August 29, 2015 14:07
-
-
Save fire/2f2948bfea7f33380452 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
import os | |
import json | |
from urllib2 import urlopen, Request | |
from sys import argv, stdout | |
if len(argv) != 3: | |
print("Usage: ./getasset.py <destination> <browser_url>") | |
exit(1) | |
[arg0,dest,url] = argv | |
if not url.startswith('https://github.com'): | |
print("Not a github asset") | |
exit(1) | |
try: | |
token=os.environ['OAUTH_TOKEN'] | |
except: | |
print("Please set OAUTH_TOKEN") | |
print("You can generate an access token at https://github.com/settings/tokens/new") | |
print("It must have repo scope") | |
exit(1) | |
repo = "/".join(url.split('/')[3:5]) | |
releases = json.loads(urlopen("https://api.github.com/repos/"+repo+"/releases?access_token="+token).read()) | |
def progress(done, sofar): | |
filled = (sofar * 72) / done | |
return '#' * filled + ' ' * (72-filled) + ("% 4.1f%%" % (float(sofar)/float(done)*100)) | |
for release in releases: | |
for asset in release['assets']: | |
if not asset['browser_download_url'] == url: | |
continue | |
req = Request(asset['url']+'?access_token='+token, None, {'Accept': 'application/octet-stream'}) | |
handle = urlopen(req) | |
length = int(handle.headers['Content-Length']) | |
with open(dest, 'wb') as f: | |
read = 0 | |
while True: | |
chunk = handle.read(4096) | |
if len(chunk): | |
f.write(chunk) | |
else: | |
break | |
read += len(chunk) | |
stdout.write('\r' + progress(length, read)) | |
stdout.flush() | |
print('') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/Engine/Build/BatchFiles/Linux/UpdateDeps.sh | |
+++ b/Engine/Build/BatchFiles/Linux/UpdateDeps.sh | |
@@ -86,6 +86,9 @@ Download() { | |
if [ "$DEP_WALLED" -eq 0 ]; then | |
echo "==> Downloading $DEP_FILE" | |
curl --progress -o $ARCHIVE_ROOT/$DEP_FILE $DEP_URL | |
+ elif [ -n "$OAUTH_TOKEN" ]; then | |
+ echo "==> Downloading $DEP_FILE" | |
+ $SCRIPT_DIR/getasset.py "$ARCHIVE_ROOT/$DEP_FILE" "$DEP_URL" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment