Skip to content
Snippets Groups Projects
Commit 94f3a6f7 authored by Rasmus Sode Lund's avatar Rasmus Sode Lund :zap:
Browse files

Add function to install DTU HAWCStab2 license

parent 908ac44a
No related branches found
No related tags found
1 merge request!292Add function to install DTU HAWCStab2 license
Pipeline #70171 failed
...@@ -131,10 +131,27 @@ def install_wind_tool( ...@@ -131,10 +131,27 @@ def install_wind_tool(
def install_hawc2_dtu_license(): def install_hawc2_dtu_license():
"""Function to install the DTU HAWC2 license. In order to install the license, you must be logged in to the DTU network.""" """Function to install the DTU HAWC2 license. In order to install the license, you must be logged in to the DTU network."""
install_dtu_license("hawc2")
def install_hawcstab2_dtu_license():
"""Function to install the DTU HAWCStab2 license. In order to install the license, you must be logged in to the DTU network."""
install_dtu_license("hawcstab2")
def install_ellipsys_dtu_license():
"""Function to install the DTU HAWCStab2 license. In order to install the license, you must be logged in to the DTU network."""
install_dtu_license("ellipsys")
def install_dtu_license(software : str):
"""Function to install the DTU online license for HAWC2, HAWCStab2 and Ellipsys. In order to install the license, you must be logged in to the DTU network."""
software = software.lower()
assert software in ["hawc2", "hawcstab2", "ellipsys"], "Argument 'software' must be one of ['hawc2', 'hawcstab2,' 'ellipsys']"
if sys.platform.lower() == "win32": if sys.platform.lower() == "win32":
f = Path(os.getenv("APPDATA")) / "DTU Wind Energy/hawc2/license.cfg" f = Path(os.getenv("APPDATA")) / f"DTU Wind Energy/{software}/license.cfg"
else: else:
f = Path.home() / ".config/hawc2/license.cfg" f = Path.home() / f".config/{software}/license.cfg"
if not f.exists(): if not f.exists():
f.parent.mkdir(parents=True, exist_ok=True) f.parent.mkdir(parents=True, exist_ok=True)
r = urlopen("http://license-internal.windenergy.dtu.dk:34523").read() r = urlopen("http://license-internal.windenergy.dtu.dk:34523").read()
...@@ -148,6 +165,8 @@ def install_hawc2_dtu_license(): ...@@ -148,6 +165,8 @@ def install_hawc2_dtu_license():
) )
def install_keygen_license(software: str, cfg_file: str, force: bool = False): def install_keygen_license(software: str, cfg_file: str, force: bool = False):
"""Install license file for HAWC2, HAWCStab2 or Ellipsys on your machine """Install license file for HAWC2, HAWCStab2 or Ellipsys on your machine
......
...@@ -5,7 +5,7 @@ import os ...@@ -5,7 +5,7 @@ import os
import pytest import pytest
from wetb.utils.installer import install_wind_tool, install_hawc2_dtu_license, install_keygen_license from wetb.utils.installer import install_wind_tool, install_hawc2_dtu_license, install_keygen_license, install_hawcstab2_dtu_license, install_ellipsys_dtu_license
import shutil import shutil
DESTINATION="/tmp/hawc2" DESTINATION="/tmp/hawc2"
...@@ -82,15 +82,21 @@ def test_version_not_available(): ...@@ -82,15 +82,21 @@ def test_version_not_available():
shutil.rmtree(DESTINATION) shutil.rmtree(DESTINATION)
def test_install_hawc2_dtu_license(): @pytest.mark.parametrize("software", ["HAwC2","HAWCStab2", "ellipsys"])
def test_install_dtu_license(software):
software = software.lower()
license_path = local_license_dir(USER_PLATFORM, "HAWC2") license_path = local_license_dir(USER_PLATFORM, "HAWC2")
try:
if software == "hawc2":
install_hawc2_dtu_license() install_hawc2_dtu_license()
assert os.path.exists(f"{local_license_dir(USER_PLATFORM, 'hawc2')}/{local_license_file('hawc2')}") elif software == "hawcstab2":
except: install_hawcstab2_dtu_license()
raise elif software == "ellipsys":
finally: install_ellipsys_dtu_license()
shutil.rmtree(license_path, ignore_errors=True)
assert os.path.exists(f"{local_license_dir(USER_PLATFORM, software)}/{local_license_file(software)}")
shutil.rmtree(license_path, ignore_errors=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment