MCPcopy Create free account
hub / github.com/NatLabRockies/SAM / ReadPythonPackageConfig

Function ReadPythonPackageConfig

src/pythonhandler.cpp:167–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167PythonPackageConfig ReadPythonPackageConfig(const std::string& name, const std::string& configFile){
168 // load python configuration
169 rapidjson::Document python_config_root;
170 std::ifstream python_config_doc(configFile);
171 if (python_config_doc.fail())
172 throw std::runtime_error("Could not open " + configFile );
173
174 std::ostringstream tmp;
175 tmp << python_config_doc.rdbuf();
176 python_config_root.Parse(tmp.str().c_str());
177
178
179 if (!python_config_root.HasMember("min_python_version"))
180 throw std::runtime_error("Missing key 'min_python_version' in " + configFile);
181 if (!python_config_root.HasMember("run_cmd"))
182 throw std::runtime_error("Missing key 'run_cmd' in " + configFile);
183 if (!python_config_root.HasMember("version"))
184 throw std::runtime_error("Missing key 'version' in " + configFile);
185
186 PythonPackageConfig config = {name,
187 python_config_root["min_python_version"].GetString(),
188 python_config_root["run_cmd"].GetString(),
189 python_config_root["version"].GetString()};
190
191 return config;
192}
193
194bool CheckPythonPackageInstalled(const std::string& package, const PythonConfig& config){
195 auto it = std::find(config.packages.begin(), config.packages.end(), package);

Callers 1

InstallPythonPackageMethod · 0.85

Calls 2

ParseMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected