|
|
|
@ -18,18 +18,18 @@ MainConfig::MainConfig() { |
|
|
|
searched_envs+=env+", "; |
|
|
|
searched_envs+=env+", "; |
|
|
|
searched_envs.erase(searched_envs.end()-2, searched_envs.end()); |
|
|
|
searched_envs.erase(searched_envs.end()-2, searched_envs.end()); |
|
|
|
searched_envs+="]"; |
|
|
|
searched_envs+="]"; |
|
|
|
throw std::runtime_error("One of these environment variables needs to point to a writable directory to save configuration." + searched_envs); |
|
|
|
throw std::runtime_error("One of these environment variables needs to point to a writable directory to save configuration: " + searched_envs); |
|
|
|
} |
|
|
|
} |
|
|
|
boost::property_tree::json_parser::read_json(config_json, cfg); |
|
|
|
boost::property_tree::json_parser::read_json(config_json, cfg); |
|
|
|
update_config_file(); |
|
|
|
update_config_file(); |
|
|
|
retrieve_config(); |
|
|
|
retrieve_config(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch(const std::exception &e) { |
|
|
|
catch(const std::exception &e) { |
|
|
|
Singleton::terminal()->print("Error reading "+ config_json + ": "+e.what()+"\n"); |
|
|
|
|
|
|
|
std::stringstream ss; |
|
|
|
std::stringstream ss; |
|
|
|
ss << configjson; |
|
|
|
ss << configjson; |
|
|
|
boost::property_tree::read_json(ss, cfg); |
|
|
|
boost::property_tree::read_json(ss, cfg); |
|
|
|
retrieve_config(); |
|
|
|
retrieve_config(); |
|
|
|
|
|
|
|
JERROR("Error reading "+ config_json + ": "+e.what()+"\n"); // logs will print to cerr when init_log haven't been run yet
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -174,11 +174,11 @@ std::vector<std::string> MainConfig::init_home_path(){ |
|
|
|
for (auto &env : locations) { |
|
|
|
for (auto &env : locations) { |
|
|
|
ptr=std::getenv(env.c_str()); |
|
|
|
ptr=std::getenv(env.c_str()); |
|
|
|
if (ptr==nullptr) |
|
|
|
if (ptr==nullptr) |
|
|
|
break; |
|
|
|
continue; |
|
|
|
else |
|
|
|
else |
|
|
|
if (boost::filesystem::exists(ptr)) { |
|
|
|
if (boost::filesystem::exists(ptr)) { |
|
|
|
home /= ".juci"; |
|
|
|
|
|
|
|
home /= ptr; |
|
|
|
home /= ptr; |
|
|
|
|
|
|
|
home /= ".juci"; |
|
|
|
return locations; |
|
|
|
return locations; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|