From af344af21b2e7303845852599717afb2c97db668 Mon Sep 17 00:00:00 2001 From: Thomas Edward Kingstone Date: Wed, 15 Nov 2023 09:00:04 +0000 Subject: [PATCH 1/3] changed paths from C;/ProgramData to %PROGRAMDATA% --- .../src/ladybugtools_toolkit/bhom/__init__.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/LadybugTools_Engine/Python/src/ladybugtools_toolkit/bhom/__init__.py b/LadybugTools_Engine/Python/src/ladybugtools_toolkit/bhom/__init__.py index 0752b46f..391e7143 100644 --- a/LadybugTools_Engine/Python/src/ladybugtools_toolkit/bhom/__init__.py +++ b/LadybugTools_Engine/Python/src/ladybugtools_toolkit/bhom/__init__.py @@ -1,17 +1,16 @@ """Root for the bhom subpackage.""" -from pathlib import Path # pylint: disable=E0401 +#from pathlib import Path # pylint: disable=E0401 +from os import path from win32api import HIWORD, LOWORD, GetFileVersionInfo -BHOM_ASSEMBLIES_DIRECTORY = Path("C:/ProgramData/BHoM/Assemblies") -BHOM_DIRECTORY = Path("C:/ProgramData/BHoM") -BHOM_LOG_FOLDER = Path("C:/ProgramData/BHoM/Logs") +BHOM_ASSEMBLIES_DIRECTORY = path.expandvars("%PROGRAMDATA%/BHoM/Assemblies") +BHOM_DIRECTORY = path.expandvars("%PROGRAMDATA%/BHoM") +BHOM_LOG_FOLDER = path.expandvars("%PROGRAMDATA%/BHoM/Logs") -PYTHON_CODE_DIRECTORY = Path("C:/ProgramData/BHoM/Extensions/PythonCode") -PYTHON_ENVIRONMENTS_DIRECTORY = Path( - "C:/ProgramData/BHoM/Extensions/PythonEnvironments" -) +PYTHON_CODE_DIRECTORY = path.expandvars("%PROGRAMDATA%/BHoM/Extensions/PythonCode") +PYTHON_ENVIRONMENTS_DIRECTORY = path.expandvars("%PROGRAMDATA%/BHoM/Extensions/PythonEnvironments") TOOLKIT_NAME = "LadybugTools_Toolkit" From 9271bb553bac2d161a067bb9bf43316bda7da28d Mon Sep 17 00:00:00 2001 From: Thomas Edward Kingstone Date: Wed, 15 Nov 2023 09:19:34 +0000 Subject: [PATCH 2/3] missed the c# ones :) --- LadybugTools_Engine/Compute/InstallPythonEnv_LBT.cs | 2 +- LadybugTools_Engine/Query/IsPollinationInstalled.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LadybugTools_Engine/Compute/InstallPythonEnv_LBT.cs b/LadybugTools_Engine/Compute/InstallPythonEnv_LBT.cs index 91d52dc1..1b75693e 100644 --- a/LadybugTools_Engine/Compute/InstallPythonEnv_LBT.cs +++ b/LadybugTools_Engine/Compute/InstallPythonEnv_LBT.cs @@ -38,7 +38,7 @@ public static partial class Compute public static PythonEnvironment InstallPythonEnv_LBT(bool run = false, bool reinstall = false) { // check if referenced Python is installed - string referencedExecutable = @"C:\Program Files\ladybug_tools\python\python.exe"; + string referencedExecutable = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles) + @"\ladybug_tools\python\python.exe"; if (!Query.IsPollinationInstalled()) { diff --git a/LadybugTools_Engine/Query/IsPollinationInstalled.cs b/LadybugTools_Engine/Query/IsPollinationInstalled.cs index 2f65592e..b10442c5 100644 --- a/LadybugTools_Engine/Query/IsPollinationInstalled.cs +++ b/LadybugTools_Engine/Query/IsPollinationInstalled.cs @@ -41,7 +41,7 @@ public static partial class Query public static bool IsPollinationInstalled(string targetPollinationVersion = "1.38.104", bool includeBuildNumber = false) { // check if referenced Python is installed - string referencedExecutable = @"C:\Program Files\ladybug_tools\python\python.exe"; + string referencedExecutable = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles) + @"\ladybug_tools\python\python.exe"; if (!File.Exists(referencedExecutable)) { Base.Compute.RecordError($"Could not find referenced python executable at {referencedExecutable}. Please install Pollination version {targetPollinationVersion} and try again."); @@ -49,7 +49,7 @@ public static bool IsPollinationInstalled(string targetPollinationVersion = "1.3 } // obtain version of pollination installed - string referencedUninstaller = @"C:\Program Files\ladybug_tools\uninstall.exe"; + string referencedUninstaller = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles) + @"\ladybug_tools\uninstall.exe"; FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(referencedUninstaller); if (includeBuildNumber && (versionInfo.ProductVersion != targetPollinationVersion)) { From 52d0a84442e37f409e3473c365ba92465187a392 Mon Sep 17 00:00:00 2001 From: Thomas Edward Kingstone Date: Wed, 15 Nov 2023 09:38:14 +0000 Subject: [PATCH 3/3] Make paths Path objects instead of strings Co-authored-by: Tristan Gerrish <10939984+tg359@users.noreply.github.com> --- .../Python/src/ladybugtools_toolkit/bhom/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/LadybugTools_Engine/Python/src/ladybugtools_toolkit/bhom/__init__.py b/LadybugTools_Engine/Python/src/ladybugtools_toolkit/bhom/__init__.py index 391e7143..0a3d66bc 100644 --- a/LadybugTools_Engine/Python/src/ladybugtools_toolkit/bhom/__init__.py +++ b/LadybugTools_Engine/Python/src/ladybugtools_toolkit/bhom/__init__.py @@ -1,16 +1,16 @@ """Root for the bhom subpackage.""" -#from pathlib import Path # pylint: disable=E0401 +from pathlib import Path # pylint: disable=E0401 from os import path from win32api import HIWORD, LOWORD, GetFileVersionInfo -BHOM_ASSEMBLIES_DIRECTORY = path.expandvars("%PROGRAMDATA%/BHoM/Assemblies") -BHOM_DIRECTORY = path.expandvars("%PROGRAMDATA%/BHoM") -BHOM_LOG_FOLDER = path.expandvars("%PROGRAMDATA%/BHoM/Logs") +BHOM_ASSEMBLIES_DIRECTORY = Path(path.expandvars("%PROGRAMDATA%/BHoM/Assemblies")) +BHOM_DIRECTORY = Path(path.expandvars("%PROGRAMDATA%/BHoM")) +BHOM_LOG_FOLDER = Path(path.expandvars("%PROGRAMDATA%/BHoM/Logs")) -PYTHON_CODE_DIRECTORY = path.expandvars("%PROGRAMDATA%/BHoM/Extensions/PythonCode") -PYTHON_ENVIRONMENTS_DIRECTORY = path.expandvars("%PROGRAMDATA%/BHoM/Extensions/PythonEnvironments") +PYTHON_CODE_DIRECTORY = Path(path.expandvars("%PROGRAMDATA%/BHoM/Extensions/PythonCode")) +PYTHON_ENVIRONMENTS_DIRECTORY = Path(path.expandvars("%PROGRAMDATA%/BHoM/Extensions/PythonEnvironments")) TOOLKIT_NAME = "LadybugTools_Toolkit"