Use the download module for printing snapshots

The script that prints new snapshots for Cargo now uses the same download module
as the rest of Cargo. Also adds a quiet option to suppress printing.
This commit is contained in:
Alex Crichton 2015-07-22 14:33:21 -07:00
parent 5cf4a89915
commit 71b522c291
2 changed files with 6 additions and 7 deletions

View file

@ -5,14 +5,14 @@ import subprocess
import sys
import tarfile
def get(url, path):
def get(url, path, quiet=False):
# see http://serverfault.com/questions/301128/how-to-download
if sys.platform == 'win32':
run(["PowerShell.exe", "/nologo", "-Command",
"(New-Object System.Net.WebClient).DownloadFile('" + url +
"', '" + path + "')"])
"', '" + path + "')"], quiet=quiet)
else:
run(["curl", "-o", path, url])
run(["curl", "-o", path, url], quiet=quiet)
def unpack(tarball, dst, quiet=False):
if quiet:

View file

@ -3,6 +3,7 @@ import os
import subprocess
import sys
import hashlib
import download
date = sys.argv[1]
@ -24,10 +25,8 @@ snaps = {
for platform in sorted(snaps):
triple = snaps[platform]
tarball = 'cargo-nightly-' + triple + '.tar.gz'
url = 'https://static-rust-lang-org.s3.amazonaws.com/cargo-dist/' + date + '/' + tarball
url = 'https://static.rust-lang.org/cargo-dist/' + date + '/' + tarball
dl_path = "target/dl/" + tarball
ret = subprocess.call(["curl", "-f", "-s", "-o", dl_path, url])
if ret != 0:
raise Exception("failed to fetch url")
download.get(url, dl_path, quiet = True)
h = hashlib.sha1(open(dl_path, 'rb').read()).hexdigest()
print(' ' + platform + ' ' + h)