Skip to content

Commit d49dc26

Browse files
committed
Add possibility to add a comment for the CCDB upload
1 parent 9220ba5 commit d49dc26

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

Detectors/TPC/dcs/macro/makeTPCCCDBEntryForDCS.C

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <string>
1515
#include "TFile.h"
1616
#include "CCDB/CcdbApi.h"
17+
#include "CommonUtils/StringUtils.h"
1718
#include "DetectorsDCS/AliasExpander.h"
1819
#include "DetectorsDCS/DeliveryType.h"
1920
#include "DetectorsDCS/DataPointIdentifier.h"
@@ -24,9 +25,10 @@
2425
#include <chrono>
2526

2627
using DPID = o2::dcs::DataPointIdentifier;
28+
using namespace o2::utils;
2729

2830
/// macro to populate CCDB for TPC with the configuration for DCS
29-
int makeTPCCCDBEntryForDCS(const std::string url = "http://localhost:8080")
31+
int makeTPCCCDBEntryForDCS(const std::string url = "http://localhost:8080", std::string comment = "")
3032
{
3133

3234
std::unordered_map<DPID, std::string> dpid2DataDesc;
@@ -64,9 +66,23 @@ int makeTPCCCDBEntryForDCS(const std::string url = "http://localhost:8080")
6466

6567
o2::ccdb::CcdbApi api;
6668
api.init(url); // or http://localhost:8080 for a local installation
67-
std::map<std::string, std::string> md;
69+
std::map<std::string, std::string> meta;
70+
71+
auto toKeyValPairs = [&meta](std::vector<std::string> const& tokens) {
72+
for (auto& token : tokens) {
73+
auto keyval = Str::tokenize(token, '=', false);
74+
if (keyval.size() != 2) {
75+
LOG(error) << "Illegal command-line key/value string: " << token;
76+
continue;
77+
}
78+
Str::trim(keyval[1]);
79+
meta[keyval[0]] = keyval[1];
80+
}
81+
};
82+
toKeyValPairs(Str::tokenize(comment, ';', true));
83+
6884
long ts = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
69-
api.storeAsTFileAny(&dpid2DataDesc, "TPC/Config/DCSDPconfig", md, ts, 99999999999999);
85+
api.storeAsTFileAny(&dpid2DataDesc, "TPC/Config/DCSDPconfig", meta, ts, 99999999999999);
7086

7187
return 0;
7288
}

0 commit comments

Comments
 (0)