Skip to content

Commit 9a9c36b

Browse files
committed
Moved configFile check + expand env vars
1 parent 70b1040 commit 9a9c36b

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Generators/src/GeneratorFactory.cxx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,6 @@ void GeneratorFactory::setPrimaryGenerator(o2::conf::SimConfig const& conf, Fair
279279
LOG(fatal) << "No configuration file provided for hybrid generator";
280280
return;
281281
}
282-
// check if file named config exists and it's not empty
283-
else if (gSystem->AccessPathName(config.c_str())) {
284-
LOG(fatal) << "Configuration file for hybrid generator does not exist";
285-
return;
286-
}
287282
auto& hybrid = o2::eventgen::GeneratorHybrid::Instance(config);
288283
primGen->AddGenerator(&hybrid);
289284
#endif

Generators/src/GeneratorHybrid.cxx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,17 +615,23 @@ Bool_t GeneratorHybrid::confSetter(const auto& gen)
615615

616616
Bool_t GeneratorHybrid::parseJSON(const std::string& path)
617617
{
618+
auto expandedPath = o2::utils::expandShellVarsInFileName(path);
619+
// Check if configuration file exists
620+
if (gSystem->AccessPathName(expandedPath.c_str())) {
621+
LOG(fatal) << "Configuration file " << expandedPath << " for hybrid generator does not exist";
622+
return false;
623+
}
618624
// Parse JSON file to build map
619-
std::ifstream fileStream(path, std::ios::in);
625+
std::ifstream fileStream(expandedPath, std::ios::in);
620626
if (!fileStream.is_open()) {
621-
LOG(error) << "Cannot open " << path;
627+
LOG(error) << "Cannot open " << expandedPath;
622628
return false;
623629
}
624630
rapidjson::IStreamWrapper isw(fileStream);
625631
rapidjson::Document doc;
626632
doc.ParseStream(isw);
627633
if (doc.HasParseError()) {
628-
LOG(error) << "Error parsing provided json file " << path;
634+
LOG(error) << "Error parsing provided json file " << expandedPath;
629635
LOG(error) << " - Error -> " << rapidjson::GetParseError_En(doc.GetParseError());
630636
return false;
631637
}

0 commit comments

Comments
 (0)