From 520487c039b828648f2c9d2578b96204c247d693 Mon Sep 17 00:00:00 2001 From: Nick Draper <nick.draper@stfc.ac.uk> Date: Tue, 7 Apr 2009 10:33:49 +0000 Subject: [PATCH] re #531 Changes to Properties files Mantid now tries to load TWO properties files Mantid.Properties as before and now a Mantid.user.properties Any entries in the user.properties file overides those on the main file. The intention is that on reinstalls we will not overwrite the user file, but are free to replace the original .properties file to add new keys etc. IMPORTANT: The release properties files are now in the Properties subdirectory, the ones in the release directory have been removed. --- Code/Installer/generateWxs.py | 2 +- .../Mantid/Build/Tests/Mantid.user.properties | 3 + Code/Mantid/Build/Tests/MantidTest.properties | 1 + .../Build/Tests/MantidTest.user.properties | 3 + .../Kernel/inc/MantidKernel/ConfigService.h | 9 +- Code/Mantid/Kernel/src/ConfigService.cpp | 559 ++++++++++-------- Code/Mantid/Kernel/test/ConfigServiceTest.h | 30 + Code/Mantid/Properties/Mantid.properties | 28 + Code/Mantid/Properties/Mantid.user.properties | 3 + Code/Mantid/Properties/Readme.txt | 12 + Code/Mantid/release/Mantid.properties | 45 -- 11 files changed, 392 insertions(+), 303 deletions(-) create mode 100644 Code/Mantid/Build/Tests/Mantid.user.properties create mode 100644 Code/Mantid/Build/Tests/MantidTest.user.properties create mode 100644 Code/Mantid/Properties/Mantid.properties create mode 100644 Code/Mantid/Properties/Mantid.user.properties create mode 100644 Code/Mantid/Properties/Readme.txt delete mode 100644 Code/Mantid/release/Mantid.properties diff --git a/Code/Installer/generateWxs.py b/Code/Installer/generateWxs.py index 13877cfc4de..6cf8c82588c 100644 --- a/Code/Installer/generateWxs.py +++ b/Code/Installer/generateWxs.py @@ -264,7 +264,7 @@ addTo(MantidDlls,'Registry',{'Id':'RegInstallDir','Root':'HKLM','Key':'Software\ addTo(MantidDlls,'Registry',{'Id':'RegMantidVersion','Root':'HKLM','Key':'Software\Mantid','Name':'Version','Action':'write','Type':'string','Value':MantidVersion}) addTo(MantidDlls,'Registry',{'Id':'RegMantidGUID','Root':'HKLM','Key':'Software\Mantid','Name':'GUID','Action':'write','Type':'string','Value':product_uuid}) # Modify Mantid.properties to set directories right -prop_file = open('../Mantid/release/Mantid.properties','r') +prop_file = open('../Mantid/Properties/Mantid.properties','r') prop_file_ins = open('Mantid.properties','w') for line in prop_file: if line.find('ManagedWorkspace.LowerMemoryLimit') >= 0: diff --git a/Code/Mantid/Build/Tests/Mantid.user.properties b/Code/Mantid/Build/Tests/Mantid.user.properties new file mode 100644 index 00000000000..7b0a094dda7 --- /dev/null +++ b/Code/Mantid/Build/Tests/Mantid.user.properties @@ -0,0 +1,3 @@ +#This file can be used to override any properties for this installation +#This file will not be replaced with futher installations of Mantid. + diff --git a/Code/Mantid/Build/Tests/MantidTest.properties b/Code/Mantid/Build/Tests/MantidTest.properties index 892b9988601..caa54de4b0f 100644 --- a/Code/Mantid/Build/Tests/MantidTest.properties +++ b/Code/Mantid/Build/Tests/MantidTest.properties @@ -1,5 +1,6 @@ #framework configuration mantid.legs = 6 +mantid.thorax = 1 #logging configuartion logging.loggers.root.level = information diff --git a/Code/Mantid/Build/Tests/MantidTest.user.properties b/Code/Mantid/Build/Tests/MantidTest.user.properties new file mode 100644 index 00000000000..15f41e020d4 --- /dev/null +++ b/Code/Mantid/Build/Tests/MantidTest.user.properties @@ -0,0 +1,3 @@ +#framework configuration +mantid.legs = 76 +mantid.noses = 5 diff --git a/Code/Mantid/Kernel/inc/MantidKernel/ConfigService.h b/Code/Mantid/Kernel/inc/MantidKernel/ConfigService.h index 72665856327..58a322689f1 100644 --- a/Code/Mantid/Kernel/inc/MantidKernel/ConfigService.h +++ b/Code/Mantid/Kernel/inc/MantidKernel/ConfigService.h @@ -115,7 +115,7 @@ class Logger; public: // Loads a config file - void loadConfig(const std::string& filename); + void loadConfig(const std::string& filename, const bool append=false); // Searches for a configuration property std::string getString(const std::string& keyName); @@ -146,11 +146,18 @@ class Logger; virtual ~ConfigServiceImpl(); + // Loads a config file + const std::string defaultConfig() const; + /// the POCO file config object WrappedObject<Poco::Util::PropertyFileConfiguration>* m_pConf; /// the POCO system Config Object WrappedObject<Poco::Util::SystemConfiguration>* m_pSysConfig; + ///The configuration properties in string format + std::string* m_pPropertyString; + + /// Convert any relative paths to absolute ones and store them locally so that /// if the working directory is altered the paths will not be affected void convertRelativePaths(); diff --git a/Code/Mantid/Kernel/src/ConfigService.cpp b/Code/Mantid/Kernel/src/ConfigService.cpp index 9b3700b0e0a..28a89c19664 100644 --- a/Code/Mantid/Kernel/src/ConfigService.cpp +++ b/Code/Mantid/Kernel/src/ConfigService.cpp @@ -6,289 +6,336 @@ #include "MantidKernel/Logger.h" #include "MantidKernel/FilterChannel.h" #include "MantidKernel/SignalChannel.h" +#include "MantidKernel/exception.h" #include "Poco/Util/LoggingConfigurator.h" #include "Poco/Util/SystemConfiguration.h" #include "Poco/Util/PropertyFileConfiguration.h" #include "Poco/LoggingFactory.h" #include "Poco/Path.h" +#include <fstream> #include <sstream> #include <iostream> #include <string> namespace Mantid { -namespace Kernel -{ + namespace Kernel + { -//------------------------------- -// Private member functions -//------------------------------- + //------------------------------- + // Private member functions + //------------------------------- - /// Private constructor for singleton class - ConfigServiceImpl::ConfigServiceImpl() : g_log(Logger::get("ConfigService")) - { - //getting at system details - m_pSysConfig = new WrappedObject<Poco::Util::SystemConfiguration>; - m_pConf = 0; - - //Register the FilterChannel with the Poco logging factory - Poco::LoggingFactory::defaultFactory().registerChannelClass("FilterChannel",new Poco::Instantiator<Poco::FilterChannel, Poco::Channel>); - - //Register the SignalChannel with the Poco logging factory - Poco::LoggingFactory::defaultFactory().registerChannelClass("SignalChannel",new Poco::Instantiator<Poco::SignalChannel, Poco::Channel>); - - //Determine how we are running mantid - if( Mantid::Kernel::getPathToExecutable().rfind("python") != std::string::npos ) - { - m_strBaseDir = Poco::Path::current(); - } - else - { - m_strBaseDir = Mantid::Kernel::getDirectoryOfExecutable(); - } - - //attempt to load the default properties file that resides in the directory of the executable - loadConfig( getBaseDir() + "Mantid.properties"); - - //Fill the list of possible relative path keys that may require conversion to absolute paths - m_vConfigPaths.clear(); - m_vConfigPaths.push_back("plugins.directory"); - m_vConfigPaths.push_back("instrumentDefinition.directory"); - m_vConfigPaths.push_back("pythonscripts.directory"); - m_vConfigPaths.push_back("ManagedWorkspace.FilePath"); - - convertRelativePaths(); - - g_log.debug() << "ConfigService created." << std::endl; - g_log.debug() << "Configured base directory of application as " << getBaseDir() << std::endl; - - } - - /// Private copy constructor for singleton class - ConfigServiceImpl::ConfigServiceImpl(const ConfigServiceImpl&) : g_log(Logger::get("ConfigService")) - { - } + /// Private constructor for singleton class + ConfigServiceImpl::ConfigServiceImpl() : g_log(Logger::get("ConfigService")) + { + //getting at system details + m_pSysConfig = new WrappedObject<Poco::Util::SystemConfiguration>; + m_pConf = 0; + m_pPropertyString = 0; - /** Private Destructor - * Prevents client from calling 'delete' on the pointer handed out by Instance - */ - ConfigServiceImpl::~ConfigServiceImpl() - { - delete m_pSysConfig; - delete m_pConf; // potential double delete??? -// g_log.debug() << "ConfigService destroyed." << std::endl; - } - - /** - * Searches the stored list for keys that have been loaded from the config file and may contain - * relative paths. Any it find are converted to absolute paths and stored separately - */ - void ConfigServiceImpl::convertRelativePaths() - { - if( m_vConfigPaths.empty() ) return; - - std::string execdir(getBaseDir()); - - std::vector<std::string>::const_iterator send = m_vConfigPaths.end(); - for( std::vector<std::string>::const_iterator sitr = m_vConfigPaths.begin(); sitr != send; ++sitr ) - { - if( !m_pConf->hasProperty(*sitr) ) continue; - - std::string value(m_pConf->getString(*sitr)); - if( Poco::Path(value).isRelative() ) - { - m_mAbsolutePaths.insert(std::make_pair(*sitr, Poco::Path(execdir).resolve(value).toString())); - } - - } - - } - -//------------------------------- -// Public member functions -//------------------------------- - - /** Loads the config file provided, any previous configuration is discarded. - * If the file contains logging setup instructions then these will be used to setup the logging framework. - * - * @param filename The filename and optionally path of the file to load - */ - void ConfigServiceImpl::loadConfig(const std::string& filename) - { - delete m_pConf; + //Register the FilterChannel with the Poco logging factory + Poco::LoggingFactory::defaultFactory().registerChannelClass("FilterChannel",new Poco::Instantiator<Poco::FilterChannel, Poco::Channel>); + + //Register the SignalChannel with the Poco logging factory + Poco::LoggingFactory::defaultFactory().registerChannelClass("SignalChannel",new Poco::Instantiator<Poco::SignalChannel, Poco::Channel>); + + //Determine how we are running mantid + if( Mantid::Kernel::getPathToExecutable().rfind("python") != std::string::npos ) + { + m_strBaseDir = Poco::Path::current(); + } + else + { + m_strBaseDir = Mantid::Kernel::getDirectoryOfExecutable(); + } + + //attempt to load the default properties file that resides in the directory of the executable + loadConfig( getBaseDir() + "Mantid.properties"); + //and then append the user properties + loadConfig( getBaseDir() + "Mantid.user.properties", true); + + //Fill the list of possible relative path keys that may require conversion to absolute paths + m_vConfigPaths.clear(); + m_vConfigPaths.push_back("plugins.directory"); + m_vConfigPaths.push_back("instrumentDefinition.directory"); + m_vConfigPaths.push_back("pythonscripts.directory"); + m_vConfigPaths.push_back("ManagedWorkspace.FilePath"); + + convertRelativePaths(); + + g_log.debug() << "ConfigService created." << std::endl; + g_log.debug() << "Configured base directory of application as " << getBaseDir() << std::endl; + + } + + /// Private copy constructor for singleton class + ConfigServiceImpl::ConfigServiceImpl(const ConfigServiceImpl&) : g_log(Logger::get("ConfigService")) + { + } - try + /** Private Destructor + * Prevents client from calling 'delete' on the pointer handed out by Instance + */ + ConfigServiceImpl::~ConfigServiceImpl() { - m_pConf = new WrappedObject<Poco::Util::PropertyFileConfiguration>(filename); + delete m_pSysConfig; + delete m_pConf; // potential double delete??? + delete m_pPropertyString; + // g_log.debug() << "ConfigService destroyed." << std::endl; } - catch (std::exception& e) + + /** + * Searches the stored list for keys that have been loaded from the config file and may contain + * relative paths. Any it find are converted to absolute paths and stored separately + */ + void ConfigServiceImpl::convertRelativePaths() + { + if( m_vConfigPaths.empty() ) return; + + std::string execdir(getBaseDir()); + + std::vector<std::string>::const_iterator send = m_vConfigPaths.end(); + for( std::vector<std::string>::const_iterator sitr = m_vConfigPaths.begin(); sitr != send; ++sitr ) + { + if( !m_pConf->hasProperty(*sitr) ) continue; + + std::string value(m_pConf->getString(*sitr)); + if( Poco::Path(value).isRelative() ) + { + m_mAbsolutePaths.insert(std::make_pair(*sitr, Poco::Path(execdir).resolve(value).toString())); + } + } + } + + /** + * Provides a default Configuration string to use if the config file cannot be loaded. + */ + const std::string ConfigServiceImpl::defaultConfig() const + { + std::string propFile = + "logging.loggers.root.level = debug\n" + "logging.loggers.root.channel.class = SplitterChannel\n" + "logging.loggers.root.channel.channel1 = consoleChannelFilter\n" + "logging.loggers.root.channel.channel2 = fileChannel\n" + "logging.channels.consoleChannelFilter.class = FilterChannel\n" + "logging.channels.consoleChannelFilter.channel = ConsoleChannel\n" + "logging.channels.consoleChannelFilter.level = information\n" + "logging.channels.consoleChannel.class = ConsoleChannel\n" + "logging.channels.consoleChannel.formatter = f1\n" + "logging.channels.fileChannel.class = FileChannel\n" + "logging.channels.fileChannel.path = mantid.log\n" + "logging.channels.fileChannel.formatter.class = PatternFormatter\n" + "logging.channels.fileChannel.formatter.pattern = %Y-%m-%d %H:%M:%S,%i [%I] %p %s - %t\n" + "logging.formatters.f1.class = PatternFormatter\n" + "logging.formatters.f1.pattern = %s-[%p] %t\n" + "logging.formatters.f1.times = UTC\n"; + return propFile; + } + + + //------------------------------- + // Public member functions + //------------------------------- + + /** Loads the config file provided. + * If the file contains logging setup instructions then these will be used to setup the logging framework. + * + * @param filename The filename and optionally path of the file to load + * @param append If false (default) then any previous configuration is discarded, otherwise the new keys are added, and repeated keys will override existing ones. + */ + void ConfigServiceImpl::loadConfig(const std::string& filename, const bool append) { - //there was a problem loading the file - it probably is not there - std::cerr << "Problem loading the logging file " << filename << " " << e.what() << std::endl; - - std::string propFile = - "logging.loggers.root.level = debug\n" - "logging.loggers.root.channel.class = SplitterChannel\n" - "logging.loggers.root.channel.channel1 = consoleChannelFilter\n" - "logging.loggers.root.channel.channel2 = fileChannel\n" - "logging.channels.consoleChannelFilter.class = FilterChannel\n" - "logging.channels.consoleChannelFilter.channel = ConsoleChannel\n" - "logging.channels.consoleChannelFilter.level = information\n" - "logging.channels.consoleChannel.class = ConsoleChannel\n" - "logging.channels.consoleChannel.formatter = f1\n" - "logging.channels.fileChannel.class = FileChannel\n" - "logging.channels.fileChannel.path = mantid.log\n" - "logging.channels.fileChannel.formatter.class = PatternFormatter\n" - "logging.channels.fileChannel.formatter.pattern = %Y-%m-%d %H:%M:%S,%i [%I] %p %s - %t\n" - "logging.formatters.f1.class = PatternFormatter\n" - "logging.formatters.f1.pattern = %s-[%p] %t\n" - "logging.formatters.f1.times = UTC\n"; - - std::istringstream istr(propFile); + delete m_pConf; + if (!append) + { + //remove the previous property string + delete m_pPropertyString; + m_pPropertyString = 0; + } + + try + { + std::ifstream propFile(filename.c_str(),std::ios::in); + bool good = propFile.good(); + + //slurp in entire file - extremely unlikely delimter used as an alternate to \n + std::string temp; + getline(propFile,temp,'¿'); + propFile.close(); + + if ((!good) || (temp=="")) + { + throw Exception::FileError("Cannot open file",filename); + } + + //store the property string + if((append) && (m_pPropertyString!=0)) + { + m_pPropertyString = new std::string(*m_pPropertyString + "\n" + temp); + } + else + { + m_pPropertyString = new std::string(temp); + } + + + //m_pConf = new WrappedObject<Poco::Util::PropertyFileConfiguration>(filename); + } + catch (std::exception& e) + { + //there was a problem loading the file - it probably is not there + std::cerr << "Problem loading the configuration file " << filename << " " << e.what() << std::endl; + + if(!append) + { + // if we have no property values then take the default + m_pPropertyString = new std::string(defaultConfig()); + } + } + //use the cached property string to initialise the POCO property file + std::istringstream istr(*m_pPropertyString); m_pConf = new WrappedObject<Poco::Util::PropertyFileConfiguration>(istr); + + try + { + //configure the logging framework + Poco::Util::LoggingConfigurator configurator; + configurator.configure(m_pConf); + } + catch (std::exception& e) + { + std::cerr << "Trouble configuring the logging framework " << e.what()<<std::endl; + } } - try + + /** Searches for a string within the currently loaded configuaration values and + * returns the value as a string. If the key is one of those that was a possible relative path + * then the local store is searched first. + * + * @param keyName The case sensitive name of the property that you need the value of. + * @returns The string value of the property, or an empty string if the key cannot be found + */ + std::string ConfigServiceImpl::getString(const std::string& keyName) { - //configure the logging framework - Poco::Util::LoggingConfigurator configurator; - - //BUG? This line crashes the FrameworkManagerTest and ConfigServiceImplTest - configurator.configure(m_pConf); + std::map<std::string, std::string>::const_iterator mitr = m_mAbsolutePaths.find(keyName); + if( mitr != m_mAbsolutePaths.end() ) + { + return (*mitr).second; + } + std::string retVal; + try + { + retVal = m_pConf->getString(keyName); + } + catch(Poco::NotFoundException& ex) + { + g_log.debug()<<"Unable to find " << keyName << " in the properties file" << std::endl; + retVal = ""; + } + return retVal; } - catch (std::exception& e) + + /** Searches for a string within the currently loaded configuaration values and + * attempts to convert the values to the template type supplied. + * + * @param keyName The case sensitive name of the property that you need the value of. + * @param out The value if found + * @returns A success flag - 0 on failure, 1 on success + */ + template<typename T> + int ConfigServiceImpl::getValue(const std::string& keyName, T& out) { - std::cerr << "Trouble configuring the logging framework " << e.what()<<std::endl; + std::string strValue = getString(keyName); + int result = StrFunc::convert(strValue,out); + return result; } - } - - - /** Searches for a string within the currently loaded configuaration values and - * returns the value as a string. If the key is one of those that was a possible relative path - * then the local store is searched first. - * - * @param keyName The case sensitive name of the property that you need the value of. - * @returns The string value of the property, or an empty string if the key cannot be found - */ - std::string ConfigServiceImpl::getString(const std::string& keyName) - { - std::map<std::string, std::string>::const_iterator mitr = m_mAbsolutePaths.find(keyName); - if( mitr != m_mAbsolutePaths.end() ) - { - return (*mitr).second; - } - std::string retVal; - try - { - retVal = m_pConf->getString(keyName); - } - catch(Poco::NotFoundException& ex) - { - g_log.debug()<<"Unable to find " << keyName << " in the properties file" << std::endl; - retVal = ""; - } - return retVal; - } - - /** Searches for a string within the currently loaded configuaration values and - * attempts to convert the values to the template type supplied. - * - * @param keyName The case sensitive name of the property that you need the value of. - * @param out The value if found - * @returns A success flag - 0 on failure, 1 on success - */ - template<typename T> - int ConfigServiceImpl::getValue(const std::string& keyName, T& out) - { - std::string strValue = getString(keyName); - int result = StrFunc::convert(strValue,out); - return result; - } - - /** Searches for the string within the environment variables and returns the - * value as a string. - * - * @param keyName The name of the environment variable that you need the value of. - * @returns The string value of the property - */ - std::string ConfigServiceImpl::getEnvironment(const std::string& keyName) - { - return m_pSysConfig->getString("system.env." + keyName); - } - - /** Gets the name of the host operating system - * - * @returns The name pf the OS version - */ - std::string ConfigServiceImpl::getOSName() - { - return m_pSysConfig->getString("system.osName"); - } - - /** Gets the name of the computer running Mantid - * - * @returns The name of the computer - */ - std::string ConfigServiceImpl::getOSArchitecture() - { - return m_pSysConfig->getString("system.osArchitecture"); - } - - /** Gets the name of the operating system Architecture - * - * @returns The operating system architecture - */ - std::string ConfigServiceImpl::getComputerName() - { - return m_pSysConfig->getString("system.nodeName"); - } - - /** Gets the name of the operating system version - * - * @returns The operating system version - */ - std::string ConfigServiceImpl::getOSVersion() - { - return m_pSysConfig->getString("system.osVersion"); - } - - /** Gets the absolute path of the current directory containing the dll - * - * @returns The absolute path of the current directory containing the dll - */ - std::string ConfigServiceImpl::getCurrentDir() - { - return m_pSysConfig->getString("system.currentDir"); - } - - /** Gets the absolute path of the temp directory - * - * @returns The absolute path of the temp directory - */ - std::string ConfigServiceImpl::getTempDir() - { - return m_pSysConfig->getString("system.tempDir"); - } - - /** - * Gets the directory that we consider to be the bse directory. Basically, this is the - * executable directory when running normally or the current directory on startup when - * running through Python on the command line - * @returns The directory to consider as the base directory, including a trailing slash - */ - std::string ConfigServiceImpl::getBaseDir() - { - return m_strBaseDir; - } - -/// \cond TEMPLATE + /** Searches for the string within the environment variables and returns the + * value as a string. + * + * @param keyName The name of the environment variable that you need the value of. + * @returns The string value of the property + */ + std::string ConfigServiceImpl::getEnvironment(const std::string& keyName) + { + return m_pSysConfig->getString("system.env." + keyName); + } + + /** Gets the name of the host operating system + * + * @returns The name pf the OS version + */ + std::string ConfigServiceImpl::getOSName() + { + return m_pSysConfig->getString("system.osName"); + } + + /** Gets the name of the computer running Mantid + * + * @returns The name of the computer + */ + std::string ConfigServiceImpl::getOSArchitecture() + { + return m_pSysConfig->getString("system.osArchitecture"); + } + + /** Gets the name of the operating system Architecture + * + * @returns The operating system architecture + */ + std::string ConfigServiceImpl::getComputerName() + { + return m_pSysConfig->getString("system.nodeName"); + } + + /** Gets the name of the operating system version + * + * @returns The operating system version + */ + std::string ConfigServiceImpl::getOSVersion() + { + return m_pSysConfig->getString("system.osVersion"); + } + + /** Gets the absolute path of the current directory containing the dll + * + * @returns The absolute path of the current directory containing the dll + */ + std::string ConfigServiceImpl::getCurrentDir() + { + return m_pSysConfig->getString("system.currentDir"); + } + + /** Gets the absolute path of the temp directory + * + * @returns The absolute path of the temp directory + */ + std::string ConfigServiceImpl::getTempDir() + { + return m_pSysConfig->getString("system.tempDir"); + } + + /** + * Gets the directory that we consider to be the bse directory. Basically, this is the + * executable directory when running normally or the current directory on startup when + * running through Python on the command line + * @returns The directory to consider as the base directory, including a trailing slash + */ + std::string ConfigServiceImpl::getBaseDir() + { + return m_strBaseDir; + } + + + /// \cond TEMPLATE - template DLLExport int ConfigServiceImpl::getValue(const std::string&,double&); - template DLLExport int ConfigServiceImpl::getValue(const std::string&,std::string&); - template DLLExport int ConfigServiceImpl::getValue(const std::string&,int&); + template DLLExport int ConfigServiceImpl::getValue(const std::string&,double&); + template DLLExport int ConfigServiceImpl::getValue(const std::string&,std::string&); + template DLLExport int ConfigServiceImpl::getValue(const std::string&,int&); -/// \endcond TEMPLATE + /// \endcond TEMPLATE -} // namespace Kernel + } // namespace Kernel } // namespace Mantid diff --git a/Code/Mantid/Kernel/test/ConfigServiceTest.h b/Code/Mantid/Kernel/test/ConfigServiceTest.h index 57fdf012685..f64bea6186c 100644 --- a/Code/Mantid/Kernel/test/ConfigServiceTest.h +++ b/Code/Mantid/Kernel/test/ConfigServiceTest.h @@ -97,6 +97,36 @@ public: std::string instrumentPath = ConfigService::Instance().getString("instrumentDefinition.directory"); TS_ASSERT( Poco::Path(instrumentPath).isAbsolute() ); } + + void TestAppendProperties() + { + + //This should clear out all old properties + ConfigService::Instance().loadConfig("MantidTest.properties"); + //this should return an empty string + TS_ASSERT_EQUALS(ConfigService::Instance().getString("mantid.noses"), ""); + //this should pass + TS_ASSERT_EQUALS(ConfigService::Instance().getString("mantid.legs"), "6"); + TS_ASSERT_EQUALS(ConfigService::Instance().getString("mantid.thorax"), "1"); + + //This should append a new properties file properties + ConfigService::Instance().loadConfig("MantidTest.user.properties",true); + //this should now be valid + TS_ASSERT_EQUALS(ConfigService::Instance().getString("mantid.noses"), "5"); + //this should have been overridden + TS_ASSERT_EQUALS(ConfigService::Instance().getString("mantid.legs"), "76"); + //this should have been left alone + TS_ASSERT_EQUALS(ConfigService::Instance().getString("mantid.thorax"), "1"); + + //This should clear out all old properties + ConfigService::Instance().loadConfig("MantidTest.properties"); + //this should return an empty string + TS_ASSERT_EQUALS(ConfigService::Instance().getString("mantid.noses"), ""); + //this should pass + TS_ASSERT_EQUALS(ConfigService::Instance().getString("mantid.legs"), "6"); + TS_ASSERT_EQUALS(ConfigService::Instance().getString("mantid.thorax"), "1"); + + } private: ConfigService *configSvc; diff --git a/Code/Mantid/Properties/Mantid.properties b/Code/Mantid/Properties/Mantid.properties new file mode 100644 index 00000000000..a97ba9a59d2 --- /dev/null +++ b/Code/Mantid/Properties/Mantid.properties @@ -0,0 +1,28 @@ +#framework configuration +mantid.legs = 6 + +#logging configuration +logging.loggers.root.level = information +logging.loggers.root.channel = fileChannel +logging.channels.fileChannel.class = FileChannel +logging.channels.fileChannel.path = Test.log +logging.channels.fileChannel.formatter.class = PatternFormatter +logging.channels.fileChannel.formatter.pattern = %Y-%m-%d %H:%M:%S,%i [%I] %p %s - %t + +#Plugin configuration +plugins.directory = ../../Bin/Plugins + +#Where to load instrument definition files from +instrumentDefinition.directory = ../../../../Test/Instrument + +# The location of the scripts directory. This is added to the python path by the +# Python API so that Mantid scripts can be imported more easily +pythonscripts.directory = ../../PythonAPI/scripts + +# Uncommenting the line below will lead to all 2D workspaces being of the ManagedWorkspace2D variety +#ManagedWorkspace.LowerMemoryLimit = 0 +ManagedWorkspace.LowerMemoryLimit = 80 +ManagedWorkspace.DataBlockSize = 4000 +ManagedWorkspace.FilePath = /nonsense/fdghjksdg + +algorithms.retained = 50 diff --git a/Code/Mantid/Properties/Mantid.user.properties b/Code/Mantid/Properties/Mantid.user.properties new file mode 100644 index 00000000000..7b0a094dda7 --- /dev/null +++ b/Code/Mantid/Properties/Mantid.user.properties @@ -0,0 +1,3 @@ +#This file can be used to override any properties for this installation +#This file will not be replaced with futher installations of Mantid. + diff --git a/Code/Mantid/Properties/Readme.txt b/Code/Mantid/Properties/Readme.txt new file mode 100644 index 00000000000..e340d105b2d --- /dev/null +++ b/Code/Mantid/Properties/Readme.txt @@ -0,0 +1,12 @@ +This folder contains the .Properties files that are to be used for release with the software. + +The installer corrects certain file paths to match those of the final configuration: +these are + plugins.directory + pythonscripts.directory + instrumentDefinition.directory + +Properties files for use in automated and development testing are in the build\tests directory. + +Note: While there is a user.properties file defined here this will only be userd for the first +installation to a client, subsequent installs will not overwrite the clients copy. \ No newline at end of file diff --git a/Code/Mantid/release/Mantid.properties b/Code/Mantid/release/Mantid.properties deleted file mode 100644 index 3bdeb2fcc72..00000000000 --- a/Code/Mantid/release/Mantid.properties +++ /dev/null @@ -1,45 +0,0 @@ -#framework configuration -plugins.directory = . - -#logging configuration -logging.loggers.root.level = information -logging.loggers.root.channel.class = SplitterChannel -logging.loggers.root.channel.channel1 = consoleChannel -logging.loggers.root.channel.channel2 = fileChannel -logging.channels.consoleChannel.class = ConsoleChannel -logging.channels.consoleChannel.formatter = f1 -logging.channels.fileChannel.class = FileChannel -logging.channels.fileChannel.path = ../logs/mantid.log -logging.channels.fileChannel.formatter.class = PatternFormatter -logging.channels.fileChannel.formatter.pattern = %Y-%m-%d %H:%M:%S,%i [%I] %p %s - %t -logging.formatters.f1.class = PatternFormatter -logging.formatters.f1.pattern = %s-[%p] %t -logging.formatters.f1.times = UTC; - -logging.loggers.root.channel.channel3 = signalChannel -logging.channels.signalChannel.class = SignalChannel - -#Where to load instrument definition files from -instrumentDefinition.directory = ../../../../Test/Instrument - -# The location of the scripts directory. This is added to the python path by the -# Python API so that Mantid scripts can be imported more easily -pythonscripts.directory = ../scripts - -# -# ManagedWorkspace.LowerMemoryLimit sets the memory limit to trigger the use of -# a ManagedWorkspace. A ManagedWorkspace will be used for a workspace requiring greater amount of memory -# than defined by LowerMemoryLimit. LowerMemoryLimit is a precentage of the physical memory available for -# the process. On Linux it is the free physical memory, on Windows it is the smaller of the free physical memory -# and the available virtual memory. The default value for LowerMemoryLimit is 40%. Setting the limit too high -# may lead to unrecoverable bad allocations. If this happens the advice is to close Mantid and relaunch it -# with a smaller LowerMemoryLimit. -# -# Uncommenting the line below will lead to all 2D workspaces being of the ManagedWorkspace2D variety -ManagedWorkspace.LowerMemoryLimit = 90 -ManagedWorkspace.DataBlockSize = 4000 -ManagedWorkspace.FilePath = ../temp - -#Uncommenting the line below will enable algorithm chain re-running whenever a -#workspace is replaced. Uncommenting and setting it to 0 will also turn it off -#AlgorithmChaining.SwitchedOn = 1 -- GitLab