mirror of
https://github.com/rust-lang/cargo
synced 2024-10-13 11:12:25 +00:00
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:
parent
5cf4a89915
commit
71b522c291
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue