16{
17 using namespace asg::msgUserCode;
19
21
22
23 if (argc < 3)
24 {
26 return -1;
27 }
28
30 const bool resubmit = (std::string (argv[2]) == "1");
31
32 std::vector<std::size_t>
indices;
34 {
35 try
36 {
37 indices.push_back (std::stoul (argv[arg]));
38 } catch (std::exception& e)
39 {
40 ANA_MSG_ERROR (
"failed to parse job index \"" << argv[arg] <<
"\": " <<
e.what());
41 return -1;
42 }
43 }
44
45 const std::string basedirName =
submitDir +
"/tmp";
46
47
48 if (!resubmit && gSystem->MakeDirectory (basedirName.c_str()) != 0)
49 {
51 return -1;
52 }
53
54 auto submitSingle = [&] (std::size_t
index)
noexcept -> StatusCode
55 {
56 try
57 {
58 const std::string
dirName = basedirName +
"/" + std::to_string (
index);
59 if (gSystem->MakeDirectory (
dirName.c_str()) != 0 && !resubmit)
60 {
62 return StatusCode::FAILURE;
63 }
64
65 std::ostringstream
cmd;
69 } catch (std::exception& e)
70 {
72 return StatusCode::FAILURE;
73 }
74 return StatusCode::SUCCESS;
75 };
76 for (std::size_t
index : indices)
77 {
78 if (submitSingle (
index).isFailure())
79 return EXIT_FAILURE;
80 }
81
82
83 std::ofstream ((submitDir + "/submitted").c_str());
85 {
86 ANA_MSG_ERROR (
"failed to retrieve job output in " + submitDir);
87 return EXIT_FAILURE;
88 }
89 return 0;
90}
static bool retrieve(const std::string &location)
retrieve all the output for the job in the given location
void exec(const std::string &cmd)
effects: execute the given command guarantee: strong failures: out of memory II failures: system fail...
std::string quote(const std::string &name)
effects: quote the given name to protect it from the shell returns: the quoted name guarantee: strong...
std::pair< long int, long int > indices
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.