From a223694fba21c3fffecf7d4fae232cfb13da98c5 Mon Sep 17 00:00:00 2001 From: Owen Arnold <owen.arnold@stfc.ac.uk> Date: Mon, 16 Apr 2012 16:49:26 +0100 Subject: [PATCH] refs #5103. Env steps towards single installer. Cleaned out a load of older checking code. Separately load up pv_plugins from normal plugins if paraview is present. --- .../Framework/API/src/FrameworkManager.cpp | 19 ++++++++ Code/Mantid/Framework/Kernel/CMakeLists.txt | 2 + .../Kernel/inc/MantidKernel/ConfigService.h | 3 ++ .../Framework/Kernel/src/ConfigService.cpp | 43 +++++++++++++------ .../Properties/Mantid.properties.template | 3 ++ .../MantidQt/API/src/InterfaceManager.cpp | 15 ------- Code/Mantid/Vates/CMakeLists.txt | 15 ------- 7 files changed, 57 insertions(+), 43 deletions(-) diff --git a/Code/Mantid/Framework/API/src/FrameworkManager.cpp b/Code/Mantid/Framework/API/src/FrameworkManager.cpp index 3231d5c5fd5..1411c909353 100644 --- a/Code/Mantid/Framework/API/src/FrameworkManager.cpp +++ b/Code/Mantid/Framework/API/src/FrameworkManager.cpp @@ -58,11 +58,30 @@ FrameworkManagerImpl::FrameworkManagerImpl() : g_log(Kernel::Logger::get("Framew _set_output_format(_TWO_DIGIT_EXPONENT); #endif + // Load plugin libraries if possible std::string pluginDir = Kernel::ConfigService::Instance().getString("plugins.directory"); if (pluginDir.length() > 0) { Mantid::Kernel::LibraryManager::Instance().OpenAllLibraries(pluginDir, false); } + // Load Paraview plugin libraries if possible + if(Kernel::ConfigService::Instance().quickParaViewCheck()) + { + const std::string pvPluginDir = Kernel::ConfigService::Instance().getString("pvplugins.directory"); + if (pvPluginDir.length() > 0) + { + this->g_log.information("Loading PV plugin libraries"); + Mantid::Kernel::LibraryManager::Instance().OpenAllLibraries(pvPluginDir, false); + } + else + { + this->g_log.information("No PV plugin library directory"); + } + } + else + { + this->g_log.information("Cannot load paraview libraries"); + } // Disable reporting errors from Nexus (they clutter up the output). NXMSetError(NULL, NexusErrorFunction); diff --git a/Code/Mantid/Framework/Kernel/CMakeLists.txt b/Code/Mantid/Framework/Kernel/CMakeLists.txt index 041e304b4e6..f6a9f589148 100644 --- a/Code/Mantid/Framework/Kernel/CMakeLists.txt +++ b/Code/Mantid/Framework/Kernel/CMakeLists.txt @@ -386,10 +386,12 @@ if (WIN32) set ( PLUGINS ${MANTID_ROOT}/${PLUGINS_DIR} ) set ( QTPLUGINS ${MANTID_ROOT}/${PLUGINS_DIR}/qtplugins/mantid ) set ( COLORMAPS_FOLDER ${MANTID_ROOT}/colormaps/ ) + set ( PV_PLUGINS ${MANTID_ROOT}/${PVPLUGINS_DIR} ) else () set ( PLUGINS ${CMAKE_INSTALL_PREFIX}/${PLUGINS_DIR} ) set ( QTPLUGINS ${CMAKE_INSTALL_PREFIX}/${PLUGINS_DIR}/qtplugins/mantid ) set ( COLORMAPS_FOLDER ${CMAKE_INSTALL_PREFIX}/colormaps/ ) + set ( PV_PLUGINS ${CMAKE_INSTALL_PREFIX}/${PVPLUGINS_DIR} ) endif () set ( PYTHONALGS ${PLUGINS}/PythonAlgs ) diff --git a/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h index 2bf6260fa75..af816a2a076 100644 --- a/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h +++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h @@ -209,6 +209,9 @@ namespace Mantid /// Set the path to the paraview libraries void setParaviewLibraryPath(const std::string& path); + /// Quick check to determine if paraview is available. + bool quickParaViewCheck() const; + /// Quick check to determine if vates has been installed. bool quickVatesCheck() const; diff --git a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp index 3ec7252bb2d..4b699cad012 100644 --- a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp +++ b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp @@ -25,6 +25,8 @@ #include <Poco/Environment.h> #include <Poco/Process.h> #include <Poco/String.h> +#include <Poco/PipeStream.h> +#include <Poco/StreamCopier.h> #include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/join.hpp> @@ -1727,6 +1729,34 @@ void ConfigServiceImpl::setParaviewLibraryPath(const std::string& path) #endif } +/* +Quick check to determine if paraview is installed. We make the assumption +that if the executable paraview binary is on the path that the paraview libraries +will also be available on the library path, or equivalent. +*/ +bool ConfigServiceImpl::quickParaViewCheck() const +{ + this->g_log.information("Checking for ParaView"); + bool isAvailable = false; + + try + { + std::string cmd("paraview"); + std::vector<std::string> args; + args.push_back("-V"); + Poco::Pipe outPipe; + Poco::ProcessHandle ph = Poco::Process::launch(cmd, args, 0, &outPipe, 0); + isAvailable = true; + this->g_log.information("ParaView is available"); + } + catch(Poco::RuntimeException& e) + { + g_log.information(e.what()); + this->g_log.information("ParaView is not available"); + } + return isAvailable; +} + /* Quick check to determine if VATES is installed. @return TRUE if available. @@ -1754,19 +1784,6 @@ bool ConfigServiceImpl::quickVatesCheck() const } ++it; } - - if(!found) - { - //On windows, the VSI gui is made available on the path. - try - { - Poco::Environment::get("MANTIDPARAVIEWPATH"); - found = true; - } - catch(Poco::NotFoundException&) - { - } - } return found; } diff --git a/Code/Mantid/Framework/Properties/Mantid.properties.template b/Code/Mantid/Framework/Properties/Mantid.properties.template index 13bf57e2c13..1fcaf8a7846 100644 --- a/Code/Mantid/Framework/Properties/Mantid.properties.template +++ b/Code/Mantid/Framework/Properties/Mantid.properties.template @@ -28,6 +28,9 @@ plugins.directory = @PLUGINS@ # Libraries to skip. The strings are searched for when loading libraries so they don't need to be exact plugins.exclude = MantidPythonAPI;dlopen +# Where to find mantid paravie plugin libraries +pvplugins.directory = @PV_PLUGINS@ + # Where to find Mantid Qt plugin libraries mantidqt.plugins.directory = @QTPLUGINS@ diff --git a/Code/Mantid/MantidQt/API/src/InterfaceManager.cpp b/Code/Mantid/MantidQt/API/src/InterfaceManager.cpp index 6f1e5cdf99a..028589aaff8 100644 --- a/Code/Mantid/MantidQt/API/src/InterfaceManager.cpp +++ b/Code/Mantid/MantidQt/API/src/InterfaceManager.cpp @@ -151,21 +151,6 @@ InterfaceManagerImpl::InterfaceManagerImpl() << std::endl; } } - - if (Poco::Environment::has("MANTIDPARAVIEWPATH")) - { - std::string vatesLibPath = Poco::Environment::get("MANTIDPARAVIEWPATH"); - int nloaded = Mantid::Kernel::LibraryManager::Instance().OpenAllLibraries(vatesLibPath); - if( nloaded == 0) - { - g_log.error() << "MANTIDPARAVIEWPATH env variable defined, but libraries cannot be loaded" - << std::endl; - } - } - else - { - g_log.information("No Vates libraries to load."); - } } /// Destructor diff --git a/Code/Mantid/Vates/CMakeLists.txt b/Code/Mantid/Vates/CMakeLists.txt index 68b2e022f96..11312d8e7cf 100644 --- a/Code/Mantid/Vates/CMakeLists.txt +++ b/Code/Mantid/Vates/CMakeLists.txt @@ -89,14 +89,6 @@ if( ParaView_FOUND AND USE_PARAVIEW ) Push \\\"$INSTDIR\\\\${PVPLUGINS_DIR}\\\" Call EnvVarUpdate Pop \\\$0 - - Push \\\"MANTIDPARAVIEWPATH\\\" - Push \\\"A\\\" - Push \\\"HKCU\\\" - Push \\\"$INSTDIR\\\\plugins\\\" - Call EnvVarUpdate - Pop \\\$0 - ") # On unistall reverse stages listed above. @@ -126,13 +118,6 @@ if( ParaView_FOUND AND USE_PARAVIEW ) Push \\\"HKCU\\\" Push \\\"$INSTDIR\\\\${PVPLUGINS_DIR}\\\" Call un.EnvVarUpdate - Pop \\\$0 - - Push \\\"MANTIDPARAVIEWPATH\\\" - Push \\\"R\\\" - Push \\\"HKCU\\\" - Push \\\"$INSTDIR\\\\plugins\\\" - Call un.EnvVarUpdate Pop \\\$0 ") -- GitLab