Skip to content

Commit 54a7b88

Browse files
authored
Merge pull request #1439 from haddocking/fix-download-links
update CNS download links
2 parents a46fbb0 + dce73c9 commit 54a7b88

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

setup.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import subprocess
77
import sys
88
import tarfile
9+
from urllib.error import HTTPError, URLError
10+
import time
911
import urllib.request
1012
from pathlib import Path
1113
from typing import cast
@@ -16,10 +18,10 @@
1618
from setuptools.command.install import install
1719

1820
CNS_BINARIES = {
19-
"x86_64-linux": "https://surfdrive.surf.nl/files/index.php/s/BWa5OimzbNliTi6/download",
20-
"x86_64-darwin": "https://surfdrive.surf.nl/files/index.php/s/3Fzzte0Zx0L8GTY/download",
21-
"arm64-darwin": "https://surfdrive.surf.nl/files/index.php/s/bYB3xPWf7iwo07X/download",
22-
"aarch64-linux": "https://surfdrive.surf.nl/files/index.php/s/3rHpxcufHGrntHn/download",
21+
"x86_64-linux": "https://surfdrive.surf.nl/public.php/dav/files/BWa5OimzbNliTi6",
22+
"x86_64-darwin": "https://surfdrive.surf.nl/public.php/dav/files/3Fzzte0Zx0L8GTY",
23+
"arm64-darwin": "https://surfdrive.surf.nl/public.php/dav/files/bYB3xPWf7iwo07X",
24+
"aarch64-linux": "https://surfdrive.surf.nl/public.php/dav/files/3rHpxcufHGrntHn",
2325
}
2426

2527
HADDOCK_RESTRAINTS_VERSION = "0.10.0"
@@ -163,13 +165,26 @@ def download_binaries(self):
163165
os.chmod(executable, 0o755)
164166

165167
@staticmethod
166-
def download_file(url, dest) -> tuple[bool, str]:
168+
def download_file(url, dest, max_retries=3, delay=2) -> tuple[bool, str]:
167169
"""Download a file from a URL"""
168-
try:
169-
urllib.request.urlretrieve(url, dest)
170-
return True, "Download successful"
171-
except Exception as e: # pylint: disable=broad-except
172-
return False, f"Download failed: {e}"
170+
for attempt in range(max_retries):
171+
try:
172+
urllib.request.urlretrieve(url, dest)
173+
return True, "Download successful"
174+
except (URLError, HTTPError) as e: # pylint: disable=broad-except
175+
if attempt < max_retries - 1:
176+
time.sleep(delay)
177+
continue
178+
return (
179+
False,
180+
f"Download of {dest} failed after {max_retries} attempts: {e} URL: {url}",
181+
)
182+
except Exception as e: # pylint: disable=broad-except
183+
return False, f"Download of {dest} failed: {e} URL: {url}"
184+
return (
185+
False,
186+
f"Download of {dest} failed after {max_retries} attempts URL: {url}",
187+
)
173188

174189
@staticmethod
175190
def get_arch():

0 commit comments

Comments
 (0)