ATLAS Offline Software
han_results_print.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 #include <cstdlib>
6 #include <filesystem>
7 #include <iostream>
8 #include <string>
9 
12 
13 namespace
14 {
15  int usage(const std::string& command_name, int exit_code);
16 
17  class CmdLineArgs
18  {
19  public:
20  int parse(int argc, char* argv[]);
21 
22  std::string command;
23  std::string hresults;
24  };
25 } // unnamed namespace
26 
27 int main ATLAS_NOT_THREAD_SAFE(int argc, char* argv[]) {
28  CmdLineArgs arg;
29  int rc = arg.parse(argc, argv);
30 
31  if (rc != 0) return rc;
32 
33  std::string resultsName(arg.hresults);
34 
35  if (!std::filesystem::exists(resultsName)) {
36  std::cerr << "File " << resultsName << " does not seem to exist. Exiting" << std::endl;
37  return 1;
38  }
39 
40  dqutils::HanOutputFile of(resultsName);
41 
42  of.printAllDQAssessments();
43  return 0;
44 }
45 
46 // ************************************************************
47 // Private Functions
48 // ************************************************************
49 
50 namespace
51 {
52  int usage(const std::string& command_name, int exit_code) {
53  std::string message;
54  message += "\n";
55  message += "This program takes as an argument the name of a \'han\' results\n";
56  message += "file and prints the statuses of all assessments to stdout.\n";
57 
58  std::string::size_type s = command_name.size();
59  std::string::size_type p = command_name.rfind('/', s);
60  std::string short_name = command_name.substr(p + 1, s);
61 
62  std::cout << "\n";
63  std::cout << "Usage: " << short_name << " <results_file>\n";
64  std::cout << message << "\n";
65  return exit_code;
66  }
67 
68  int CmdLineArgs::parse(int argc, char* argv[]) {
69  command = argv[0];
70  if (argc > 2) return usage(command, 1);
71 
72  if (argc < 2) return usage(command, 0);
73 
74  hresults = argv[1];
75  return 0;
76  }
77 } // unnamed namespace
AtlCoolConsole.usage
tuple usage
Definition: AtlCoolConsole.py:443
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
LB_AnalMapSplitter.of
of
Definition: LB_AnalMapSplitter.py:48
parse
std::map< std::string, std::string > parse(const std::string &list)
Definition: egammaLayerRecalibTool.cxx:983
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
HanOutputFile.h
ReweightUtils.message
message
Definition: ReweightUtils.py:15
main
int main(int, char **)
Main class for all the CppUnit test classes
Definition: CppUnit_SGtestdriver.cxx:141
dqutils::HanOutputFile
Definition: HanOutputFile.h:32
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
create_dcsc_inputs_sqlite.arg
list arg
Definition: create_dcsc_inputs_sqlite.py:48
ATLAS_NOT_THREAD_SAFE
int main ATLAS_NOT_THREAD_SAFE(int argc, char *argv[])
Definition: han_results_print.cxx:27
python.dummyaccess.exists
def exists(filename)
Definition: dummyaccess.py:9
checker_macros.h
Define macros for attributes used to control the static checker.
get_generator_info.command
string command
Definition: get_generator_info.py:38