Skip to content

Commit d54fbc8

Browse files
committed
Merge bitcoin/bitcoin#30703: test: Avoid duplicate curl call in get_previous_releases.py
fa5aeab test: Avoid duplicate curl call in get_previous_releases.py (MarcoFalke) Pull request description: Seems odd having to translate `404` to "Binary tag was not found". Also, it seems odd to write a for-loop over a list with one item. Fix both issues by just using a single call to `curl --fail ...`. Can be tested with: `test/get_previous_releases.py -b v99.99.99` Before: ``` Releases directory: releases Fetching: https://bitcoincore.org/bin/bitcoin-core-99.99.99/bitcoin-99.99.99-x86_64-linux-gnu.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 286k 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0 Binary tag was not found ``` After: ``` Releases directory: releases Fetching: https://bitcoincore.org/bin/bitcoin-core-99.99.99/bitcoin-99.99.99-x86_64-linux-gnu.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 286k 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0 curl: (22) The requested URL returned error: 404 ACKs for top commit: fanquake: ACK fa5aeab brunoerg: utACK fa5aeab tdb3: tested ACK fa5aeab Tree-SHA512: d5d31e0bccdd9de9b4a8ecf2e69348f4e8cee773050c8259b61db1ce5de73f6fbfffbe8c4d2571f7bef2de29cb42fd244573deebfbec614e487e76ef41681b9c
2 parents c81c6bf + fa5aeab commit d54fbc8

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

test/get_previous_releases.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,9 @@ def download_binary(tag, args) -> int:
133133

134134
print('Fetching: {tarballUrl}'.format(tarballUrl=tarballUrl))
135135

136-
header, status = subprocess.Popen(
137-
['curl', '--head', tarballUrl], stdout=subprocess.PIPE).communicate()
138-
if re.search("404 Not Found", header.decode("utf-8")):
139-
print("Binary tag was not found")
140-
return 1
141-
142-
curlCmds = [
143-
['curl', '--remote-name', tarballUrl]
144-
]
145-
146-
for cmd in curlCmds:
147-
ret = subprocess.run(cmd).returncode
148-
if ret:
149-
return ret
136+
ret = subprocess.run(['curl', '--fail', '--remote-name', tarballUrl]).returncode
137+
if ret:
138+
return ret
150139

151140
hasher = hashlib.sha256()
152141
with open(tarball, "rb") as afile:

0 commit comments

Comments
 (0)