10#include "boost/algorithm/string.hpp"
11#include "boost/filesystem.hpp"
17namespace fs = boost::filesystem;
21fs::path Env::cwd_ = fs::current_path();
23std::string Env::instdir_ =
"";
29 index = path.rfind(
"/");
30 base = path.substr(0, index);
35 if (instdir_.length() > 0)
37 std::array<char, PATH_MAX>
buffer;
41 throw std::runtime_error(
"popen() failed!");
63 std::string
blddir =
"/cyclus/build";
69 std::cout <<
"resized builddir " <<
blddir <<
"\n";
99 std::string
p =
GetEnv(
"CYCLUS_NUC_DATA");
100 if (
p !=
"" && fs::exists(
p)) {
114 throw IOError(
"cyclus_nuc_data.h5 not found in "
115 " environment variable CYCLUS_NUC_DATA or "
121 std::string
p =
GetEnv(
"CYCLUS_RNG_SCHEMA");
122 if (
p !=
"" && fs::exists(
p)) {
135 throw IOError(
"cyclus.rng.in not found in "
136 " environment variable CYCLUS_RNG_SCHEMA or "
148 throw IOError(
"cyclus-flat.rng.in not found in "
149 " environment variable CYCLUS_RNG_SCHEMA or "
156 std::string
s =
GetEnv(
"CYCLUS_PATH");
157 std::vector<std::string>
strs;
170 std::string
s = std::string(
envvar);
171 std::transform(
s.begin(),
s.end(),
s.begin(),
::tolower);
172 return !(
s ==
"" ||
s ==
"f" ||
s ==
"false" ||
s ==
"0");
177 std::cout << __FILE__ << ":" << __LINE__ << ": "#X" = " << X << "\n"
184 boost::system::error_code
errc;
187 for (
int i = 0; i <
strs.size(); ++i) {
188 fs::path
full = fs::path(
strs[i]) / path;
190 return full.string();
195 if (!
pymod.empty()) {
199 throw IOError(
"No module found for path " + path);
static const std::string rng_schema(bool flat=false)
Returns the current rng schema.
static const std::string GetInstallPath()
The relative path to the root install directory (containing bin, lib, etc.) This first checks the pat...
static const std::string PathDelimiter()
static const bool allow_milps()
static std::string FindModule(std::string path)
Returns the full path to a module by searching through default install and CYCLUS_PATH directories.
static std::string GetEnv(std::string var)
Method to check the existence of and return an environment variable.
static std::string PathBase(std::string path)
the path basis
static const std::string EnvDelimiter()
static const std::string GetBuildPath()
The relative path to the root build directory (containing bin, lib, etc.)
static const std::string nuc_data()
static const std::vector< std::string > cyclus_path()
for failed reading/writing to files, network connections, etc..
Code providing rudimentary logging capability for the Cyclus core.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
std::string PyFindModule(std::string lib)
Finds a Python module and returns its filename.
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters