You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prior to running the environment installer or any other code within the toolkit, a check should be made to ensure that Pollination is installed, and the version installed is the one that the code has been tested against.
Not sure why I didn't do this sooner, but it would look something like this:
namespaceBH.Engine.LadybugTools{publicstaticpartialclassQuery{[Description("Return True if Pollination is installed to the currently supported version.")][Input("targetPollinationVersion","The target Pollination build BHoM currently supports.")][Input("includeBuildNumber","If true, the build number will be included in the comparison.")][Output("bool","True if Pollination is installed to the currently supported version.")]publicstaticboolIsPollinationInstalled(stringtargetPollinationVersion,boolincludeBuildNumber){// check if referenced Python is installedstringreferencedExecutable=@"C:\Program Files\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.");returnfalse;}// obtain version of pollination installedstringreferencedUninstaller=@"C:\Program Files\ladybug_tools\uninstall.exe";FileVersionInfoversionInfo=FileVersionInfo.GetVersionInfo(referencedUninstaller);if(includeBuildNumber){if(versionInfo.ProductVersion!=targetPollinationVersion){Base.Compute.RecordError($"Polination version installed ({versionInfo.ProductVersion}) is not the same as the version required for this code to function correctly ({targetPollinationVersion}).");returnfalse;}}// check that version matches the target versionintmajor=int.Parse(targetPollinationVersion.Split('.')[0]);intminor=int.Parse(targetPollinationVersion.Split('.')[1]);if(versionInfo.ProductMajorPart!=major||versionInfo.ProductMinorPart!=minor){if(versionInfo.ProductVersion!=targetPollinationVersion){Base.Compute.RecordError($"Polination version installed ({versionInfo.ProductVersion}) is not the same as the version required for this code to function correctly ({targetPollinationVersion}).");returnfalse;}}returntrue;}}}
The text was updated successfully, but these errors were encountered:
Description:
Prior to running the environment installer or any other code within the toolkit, a check should be made to ensure that Pollination is installed, and the version installed is the one that the code has been tested against.
Not sure why I didn't do this sooner, but it would look something like this:
The text was updated successfully, but these errors were encountered: