Skip to content

Commit 04ebaba

Browse files
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.
2 parents 32bb73e + 4259073 commit 04ebaba

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/bootstrap/bootstrap.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ def _download(path, url, probably_big, verbose, exception):
8787
# If curl is not present on Win32, we should not sys.exit
8888
# but raise `CalledProcessError` or `OSError` instead
8989
require(["curl", "--version"], exception=platform_is_win32)
90-
run(["curl", option,
91-
"-L", # Follow redirect.
92-
"-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds
93-
"--connect-timeout", "30", # timeout if cannot connect within 30 seconds
94-
"--retry", "3", "-Sf", "-o", path, url],
95-
verbose=verbose,
96-
exception=True, # Will raise RuntimeError on failure
97-
)
90+
with open(path, "wb") as outfile:
91+
run(["curl", option,
92+
"-L", # Follow redirect.
93+
"-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds
94+
"--connect-timeout", "30", # timeout if cannot connect within 30 seconds
95+
"--retry", "3", "-Sf", url],
96+
stdout=outfile, #Implements cli redirect operator '>'
97+
verbose=verbose,
98+
exception=True, # Will raise RuntimeError on failure
99+
)
98100
except (subprocess.CalledProcessError, OSError, RuntimeError):
99101
# see http://serverfault.com/questions/301128/how-to-download
100102
if platform_is_win32:

0 commit comments

Comments
 (0)