Skip to content

Commit

Permalink
refs #5103. Env steps towards single installer.
Browse files Browse the repository at this point in the history
Cleaned out a load of older checking code. Separately load up pv_plugins from normal plugins if paraview is present.
  • Loading branch information
OwenArnold committed Apr 16, 2012
1 parent 9a688cf commit a223694
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 43 deletions.
19 changes: 19 additions & 0 deletions Code/Mantid/Framework/API/src/FrameworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/Kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
43 changes: 30 additions & 13 deletions Code/Mantid/Framework/Kernel/src/ConfigService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/Properties/Mantid.properties.template
Original file line number Diff line number Diff line change
Expand Up @@ -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@

Expand Down
15 changes: 0 additions & 15 deletions Code/Mantid/MantidQt/API/src/InterfaceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions Code/Mantid/Vates/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
")

Expand Down

0 comments on commit a223694

Please sign in to comment.