Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
89626764
Commit
89626764
authored
8 years ago
by
Samuel Jackson
Browse files
Options
Downloads
Patches
Plain Diff
Refs #18676 Check outside package for .properties file
parent
73eabf4a
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/Kernel/inc/MantidKernel/ConfigService.h
+2
-0
2 additions, 0 deletions
Framework/Kernel/inc/MantidKernel/ConfigService.h
Framework/Kernel/src/ConfigService.cpp
+50
-22
50 additions, 22 deletions
Framework/Kernel/src/ConfigService.cpp
with
52 additions
and
22 deletions
Framework/Kernel/inc/MantidKernel/ConfigService.h
+
2
−
0
View file @
89626764
...
@@ -121,6 +121,8 @@ public:
...
@@ -121,6 +121,8 @@ public:
std
::
string
m_prev
;
///< The previous value for the property
std
::
string
m_prev
;
///< The previous value for the property
};
};
/// Setup the base directory
void
setBaseDirectory
();
/// Reset to "factory" settings. Removes current user properties
/// Reset to "factory" settings. Removes current user properties
void
reset
();
void
reset
();
/// Wipe out the current configuration and load a new one
/// Wipe out the current configuration and load a new one
...
...
This diff is collapsed.
Click to expand it.
Framework/Kernel/src/ConfigService.cpp
+
50
−
22
View file @
89626764
...
@@ -160,28 +160,7 @@ ConfigServiceImpl::ConfigServiceImpl()
...
@@ -160,28 +160,7 @@ ConfigServiceImpl::ConfigServiceImpl()
"StdoutChannel"
,
"StdoutChannel"
,
new
Poco
::
Instantiator
<
Poco
::
StdoutChannel
,
Poco
::
Channel
>
);
new
Poco
::
Instantiator
<
Poco
::
StdoutChannel
,
Poco
::
Channel
>
);
// Define the directory to search for the Mantid.properties file.
setBaseDirectory
();
Poco
::
File
f
;
// First directory: the current working
m_strBaseDir
=
Poco
::
Path
::
current
();
f
=
Poco
::
File
(
m_strBaseDir
+
m_properties_file_name
);
if
(
!
f
.
exists
())
{
// Check the executable directory to see if it includes a mantid.properties
// file
m_strBaseDir
=
getDirectoryOfExecutable
();
f
=
Poco
::
File
(
m_strBaseDir
+
m_properties_file_name
);
if
(
!
f
.
exists
())
{
// Last, use the MANTIDPATH environment var
if
(
Poco
::
Environment
::
has
(
"MANTIDPATH"
))
{
// Here we have to follow the convention of the rest of this code and
// add a trailing slash.
// Note: adding it to the MANTIDPATH itself will make other parts of the
// code crash.
m_strBaseDir
=
Poco
::
Environment
::
get
(
"MANTIDPATH"
)
+
"/"
;
}
}
}
// Fill the list of possible relative path keys that may require conversion to
// Fill the list of possible relative path keys that may require conversion to
// absolute paths
// absolute paths
...
@@ -285,6 +264,55 @@ ConfigServiceImpl::~ConfigServiceImpl() {
...
@@ -285,6 +264,55 @@ ConfigServiceImpl::~ConfigServiceImpl() {
clearFacilities
();
clearFacilities
();
}
}
/**
* Set the base directory path so we can file the Mantid.properties file.
*
* This will search for the base directory that contains the .properties file
* by checking the following places:
* - The current working directory
* - The executable directory
* - The directory defined by the MANTIDPATH enviroment var
* - OSX only: the directory two directories up from the executable (which
* is the base on the OSX package.
*
*/
void
ConfigServiceImpl
::
setBaseDirectory
()
{
// Define the directory to search for the Mantid.properties file.
Poco
::
File
f
;
// First directory: the current working
m_strBaseDir
=
Poco
::
Path
::
current
();
f
=
Poco
::
File
(
m_strBaseDir
+
m_properties_file_name
);
if
(
f
.
exists
())
return
;
// Check the executable directory to see if it includes a mantid.properties
// file
m_strBaseDir
=
getDirectoryOfExecutable
();
f
=
Poco
::
File
(
m_strBaseDir
+
m_properties_file_name
);
if
(
f
.
exists
())
return
;
// Check the MANTIDPATH environment var
if
(
Poco
::
Environment
::
has
(
"MANTIDPATH"
))
{
// Here we have to follow the convention of the rest of this code and
// add a trailing slash.
// Note: adding it to the MANTIDPATH itself will make other parts of the
// code crash.
m_strBaseDir
=
Poco
::
Environment
::
get
(
"MANTIDPATH"
)
+
"/"
;
f
=
Poco
::
File
(
m_strBaseDir
+
m_properties_file_name
);
if
(
!
f
.
exists
())
return
;
}
#ifdef __APPLE__
// Finally, on OSX check if we're in the package directory and the .properties
// file just happens to be two directories up
auto
path
=
Poco
::
Path
(
getDirectoryOfExecutable
());
m_strBaseDir
=
path
.
parent
().
parent
().
parent
().
toString
();
#endif
}
/** Loads the config file provided.
/** Loads the config file provided.
* If the file contains logging setup instructions then these will be used to
* If the file contains logging setup instructions then these will be used to
*setup the logging framework.
*setup the logging framework.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment