Created
March 7, 2017 21:43
-
-
Save dereckmartin/215363e111f9e062a1dfeee6250c6429 to your computer and use it in GitHub Desktop.
Download latest packer version for linux
This file contains hidden or 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 python3 | |
import requests | |
from tqdm import tqdm | |
req = requests.get("https://api.github.com/repos/mitchellh/packer/tags") | |
data = req.json() | |
version = data[0]['name'] | |
url = "https://releases.hashicorp.com/packer/%s/packer_%s_linux_amd64.zip" % (version[1:],version[1:]) | |
response = requests.get(url, stream=True) | |
total = int(response.headers['content-length']) | |
with open('packer-latest.tar.gz', 'wb') as f: | |
for data in tqdm(response.iter_content(),total=total,unit='B', unit_scale=True): | |
f.write(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment