Skip to content

Instantly share code, notes, and snippets.

@dereckmartin
Created March 7, 2017 21:43
Show Gist options
  • Save dereckmartin/215363e111f9e062a1dfeee6250c6429 to your computer and use it in GitHub Desktop.
Save dereckmartin/215363e111f9e062a1dfeee6250c6429 to your computer and use it in GitHub Desktop.
Download latest packer version for linux
#!/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