diff options
| author | Michael Goulet <michael@errs.io> | 2023-02-08 20:01:25 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-08 20:01:25 -0800 |
| commit | 04ebaba17b60275df2920e75654c3691e45865a0 (patch) | |
| tree | a2a392c8453b0b787732ab359dcc1cc97f6a470a | |
| parent | 32bb73eedef784a3a4a3225805e0977014cd5c72 (diff) | |
| parent | 4259073e9a5bedd25f4860ddec2be55d995b4b9d (diff) | |
| download | rust-04ebaba17b60275df2920e75654c3691e45865a0.tar.gz rust-04ebaba17b60275df2920e75654c3691e45865a0.zip | |
Rollup merge of #107790 - tharunsuresh-code:snap_curl, r=jyn514
x.py fails all downloads that use a tempdir with snap curl #107722 Have used the open() library from python to capture the binary output of the curl command and write it to a file using stdout of the subprocess. Added a single-line comment mentioning the redirect operator.
| -rw-r--r-- | src/bootstrap/bootstrap.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 5b19a658fb5..c298817895c 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -87,14 +87,16 @@ def _download(path, url, probably_big, verbose, exception): # If curl is not present on Win32, we should not sys.exit # but raise `CalledProcessError` or `OSError` instead require(["curl", "--version"], exception=platform_is_win32) - run(["curl", option, - "-L", # Follow redirect. - "-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds - "--connect-timeout", "30", # timeout if cannot connect within 30 seconds - "--retry", "3", "-Sf", "-o", path, url], - verbose=verbose, - exception=True, # Will raise RuntimeError on failure - ) + with open(path, "wb") as outfile: + run(["curl", option, + "-L", # Follow redirect. + "-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds + "--connect-timeout", "30", # timeout if cannot connect within 30 seconds + "--retry", "3", "-Sf", url], + stdout=outfile, #Implements cli redirect operator '>' + verbose=verbose, + exception=True, # Will raise RuntimeError on failure + ) except (subprocess.CalledProcessError, OSError, RuntimeError): # see http://serverfault.com/questions/301128/how-to-download if platform_is_win32: |
