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

Fix bug in fstring

parent b64a7bcd
No related branches found
No related tags found
1 merge request!281Fix bug in fstring
Pipeline #66140 passed with warnings
...@@ -13,8 +13,12 @@ from urllib import request ...@@ -13,8 +13,12 @@ from urllib import request
import ssl import ssl
import certifi import certifi
def urlopen(*args, **kwargs): def urlopen(*args, **kwargs):
return request.urlopen(*args, **kwargs, context=ssl.create_default_context(cafile=certifi.where())) return request.urlopen(
*args, **kwargs, context=ssl.create_default_context(cafile=certifi.where())
)
def chmod_x(exe_path: str): def chmod_x(exe_path: str):
"""Utility function to change the file mode of a file to allow execution """Utility function to change the file mode of a file to allow execution
...@@ -46,7 +50,7 @@ def install_wind_tool( ...@@ -46,7 +50,7 @@ def install_wind_tool(
""" """
# Escape backslash if windowspath is given # Escape backslash if windowspath is given
destination = Path(destination.encode('unicode_escape').decode()).as_posix() destination = Path(destination.encode("unicode_escape").decode()).as_posix()
if tool is None: if tool is None:
print("No tool has been given for install. Nothing has been installed.") print("No tool has been given for install. Nothing has been installed.")
...@@ -76,7 +80,7 @@ def install_wind_tool( ...@@ -76,7 +80,7 @@ def install_wind_tool(
# Check if requested version is available, and default it is not. # Check if requested version is available, and default it is not.
if version is not None and version not in versions[tool]["available"]: if version is not None and version not in versions[tool]["available"]:
print( print(
f"Version '{version}' of '{tool}' is not available - defaulting to the latest version: '{versions[tool]["latest"]}'" f"Version '{version}' of '{tool}' is not available - defaulting to the latest version: '{versions[tool]['latest']}'"
) )
version = versions[tool]["latest"] version = versions[tool]["latest"]
elif version is None: elif version is None:
...@@ -130,12 +134,14 @@ def install_hawc2_dtu_license(): ...@@ -130,12 +134,14 @@ def install_hawc2_dtu_license():
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")) / "DTU Wind Energy/hawc2/license.cfg"
else: else:
f = Path.home() / '.config/hawc2/license.cfg' f = Path.home() / ".config/hawc2/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()
if b"LICENSE SERVER RUNNING" in r: if b"LICENSE SERVER RUNNING" in r:
f.write_text("[licensing]\nhost = http://license-internal.windenergy.dtu.dk\nport = 34523") f.write_text(
"[licensing]\nhost = http://license-internal.windenergy.dtu.dk\nport = 34523"
)
else: else:
raise ConnectionError( raise ConnectionError(
f"Could not connect to the DTU license server. You must be connected to the DTU network to use this function." f"Could not connect to the DTU license server. You must be connected to the DTU network to use this function."
......
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