Skip to content

Instantly share code, notes, and snippets.

@Scrxtchy
Created April 20, 2017 07:22
Show Gist options
  • Save Scrxtchy/fdc528f374107607ec470bf78c091740 to your computer and use it in GitHub Desktop.
Save Scrxtchy/fdc528f374107607ec470bf78c091740 to your computer and use it in GitHub Desktop.
downloads quaternion from appveyor
#https://ci.appveyor.com/api/projects/sharex/sharex/
#https://ci.appveyor.com/api/buildjobs/gvpcphtdc5pnsy3d/artifacts/ShareX.Setup%2FInnoSetup%2FOutput%2FShareX-portable.zip
import requests, json, urllib.request, zipfile, os
r = requests.get('https://ci.appveyor.com/api/projects/Fxrh/quaternion/')
data = json.loads(r.text)
#buildId = data['build']['jobs'][0]['jobId']
#print(data['build']['jobs'][0]['jobId'])
for i in data['build']['jobs']:
print(i['name'])
if i['name'].find('64') != -1:
buildId = i['jobId']
print('downloading release')
def reporthook(blocknum, blocksize, totalsize): #https://stackoverflow.com/questions/13881092/download-progressbar-for-python-3
readsofar = blocknum * blocksize
if totalsize > 0:
percent = readsofar * 1e2 / totalsize
s = "\r%5.1f%% %*d / %d" % (
percent, len(str(totalsize)), readsofar, totalsize)
print(s)
if readsofar >= totalsize: # near the end
print("\n")
else: # total size is unknown
print("read %d\n" % (readsofar,))
qtnzip = urllib.request.urlretrieve("https://ci.appveyor.com/api/buildjobs/%s/artifacts/quaternion.zip" % buildId, 'quaternion.zip', reporthook)
print('download complete')
qtnzip = zipfile.ZipFile('quaternion.zip')
qtnzip.extractall('D:\Scratch\Desktop\Quaternion')
print('Portable Version dumped to %s\nDeleting Zip' %'D:\Scratch\Desktop\Quaternion')
qtnzip.close()
os.remove('quaternion.zip')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment