Skip to content

Commit 8b1cc91

Browse files
committed
download: remove support for build selection
1 parent 8d366cb commit 8b1cc91

File tree

1 file changed

+10
-90
lines changed

1 file changed

+10
-90
lines changed

ogs5py/tools/download.py

Lines changed: 10 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,9 @@
2121
import platform
2222
import shutil
2323
import tarfile
24-
import tempfile
2524
import zipfile
26-
from urllib.request import urlopen, urlretrieve
27-
28-
import lxml.html
29-
30-
31-
# TemporaryDirectory not avialable in python2
32-
# from: https://gist.github.com/cpelley/10e2eeaf60dacc7956bb
33-
class _TemporaryDirectory(object):
34-
def __enter__(self):
35-
self.dir_name = tempfile.mkdtemp()
36-
return self.dir_name
37-
38-
def __exit__(self, exc_type, exc_value, traceback):
39-
shutil.rmtree(self.dir_name)
40-
41-
42-
TemporaryDirectory = getattr(
43-
tempfile, "TemporaryDirectory", _TemporaryDirectory
44-
)
45-
46-
47-
# https://stackoverflow.com/a/34615446/6696397
48-
def get_links(url, ext, build=None):
49-
"""Get links from url ending with ext and containing build."""
50-
sublinks = []
51-
connection = urlopen(url)
52-
dom = lxml.html.fromstring(connection.read())
53-
for link in dom.xpath("//a/@href"):
54-
if not link or not link.endswith(ext):
55-
continue # skip unwanted
56-
if build is None or "build_" + build + "/" in link:
57-
sublinks.append(
58-
url + link if not link.startswith("http") else link
59-
)
60-
return sublinks
61-
62-
63-
RELEASE = "https://ogsstorage.blob.core.windows.net/binaries/ogs5/"
64-
BUILD = "https://jenkins.opengeosys.org/job/ufz/job/ogs5/job/master/"
65-
STABLE = BUILD + "lastStableBuild/"
66-
SUCCESS = BUILD + "lastSuccessfulBuild/"
25+
from tempfile import TemporaryDirectory
26+
from urllib.request import urlretrieve
6727

6828
# https://stackoverflow.com/a/53222876/6696397
6929
OGS5PY_CONFIG = os.path.join(
@@ -74,6 +34,8 @@ def get_links(url, ext, build=None):
7434
)
7535
"""str: Standard config path for ogs5py."""
7636

37+
RELEASE = "https://ogsstorage.blob.core.windows.net/binaries/ogs5/"
38+
7739
URLS = {
7840
"5.7": {
7941
"Linux": (
@@ -84,8 +46,7 @@ def get_links(url, ext, build=None):
8446
},
8547
"5.7.1": {
8648
"Windows": (
87-
"https://github.com/ufz/ogs5/releases/download/"
88-
+ "5.7.1/ogs-5.7.1-Windows-x64.zip"
49+
"https://github.com/ufz/ogs5/releases/download/5.7.1/ogs-5.7.1-Windows-x64.zip"
8950
)
9051
},
9152
"5.8": {
@@ -106,7 +67,7 @@ def download_ogs(
10667
Parameters
10768
----------
10869
version : :class:`str`, optional
109-
Version to download ("5.7", "5.8", "latest" or "stable").
70+
Version to download ("5.7", "5.8", "5.7.1").
11071
Default: "5.7"
11172
system : :class:`str`, optional
11273
Target system (Linux, Windows, Darwin). Default: platform.system()
@@ -115,20 +76,7 @@ def download_ogs(
11576
name : :class:`str`, optional
11677
Destination file name. Default "ogs[.exe]"
11778
build : :class:`str`, optional
118-
If system is "Linux" and version is "latest" or "stable",
119-
you can select a certain build from the ogs 5 builds:
120-
121-
* "BRNS": Biogeochemical Reaction Network Simulator
122-
* "FEM": Finite Element Method
123-
* "GEMS": Gibbs Energy Minimization Solver
124-
* "IPQC": IPhreeqc
125-
* "LIS": Library of Iterative Solvers
126-
* "MKL": Intel Math Kernel Library
127-
* "MPI": Message Passing Interface
128-
* "PETSC": Portable, Extensible Toolkit for Scientific Computation
129-
* "PETSC_GEMS": PETSC and GEMS
130-
* "PQC": PHREEQC
131-
* "SP": Sparse solver
79+
Only None and "FEM" supported.
13280
13381
Returns
13482
-------
@@ -143,18 +91,11 @@ def download_ogs(
14391
Taken from:
14492
14593
* https://www.opengeosys.org/ogs-5/
146-
* https://jenkins.opengeosys.org/job/ufz/job/ogs5/job/master/
14794
"""
148-
URLS["latest"] = {
149-
"Linux": get_links(SUCCESS, "tar.gz", build="FEM")[0],
150-
"Windows": get_links(SUCCESS, "zip", build=None)[0],
151-
}
152-
URLS["stable"] = {
153-
"Linux": get_links(STABLE, "tar.gz", build="FEM")[0],
154-
"Windows": get_links(STABLE, "zip", build=None)[0],
155-
}
15695
system = platform.system() if system is None else system
15796
path = os.path.abspath(path)
97+
if build not in [None, "FEM"]:
98+
raise ValueError("download_ogs: only build='FEM' supported")
15899
if not os.path.exists(path):
159100
os.makedirs(path)
160101
if version not in URLS:
@@ -168,28 +109,7 @@ def download_ogs(
168109
system, version, list(urls_version)
169110
)
170111
)
171-
if system == "Linux" and build is not None:
172-
if version not in ["stable", "latest"]:
173-
raise ValueError(
174-
"Use version 'stable' or 'latest' for specific build."
175-
)
176-
base_url = STABLE if version == "stable" else SUCCESS
177-
links = get_links(base_url, ".tar.gz", build)
178-
if len(links) != 1:
179-
raise ValueError(
180-
"Can't find unique version for build '{}'. Found: {}".format(
181-
build, links
182-
)
183-
)
184-
ogs_url = links[0]
185-
elif build is None or build == "FEM":
186-
ogs_url = urls_version[system]
187-
else:
188-
raise ValueError(
189-
"system='{}', build='{}': Could not find matching exe.".format(
190-
system, build
191-
)
192-
)
112+
ogs_url = urls_version[system]
193113
print("Downloading: ", ogs_url)
194114
ext = ".tar.gz" if ogs_url.endswith(".tar.gz") else ".zip"
195115
if name is None:

0 commit comments

Comments
 (0)