comparison OrthancServer/Scheduler/CallSystemCommand.cpp @ 1099:060e8918d7a4

More fault-tolerant commands in Lua scripts
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 07 Aug 2014 10:02:22 +0200
parents 921532f67770
children 6e7e5ed91c2d
comparison
equal deleted inserted replaced
1098:50c889af583b 1099:060e8918d7a4
53 for (ListOfStrings::const_iterator 53 for (ListOfStrings::const_iterator
54 it = inputs.begin(); it != inputs.end(); ++it) 54 it = inputs.begin(); it != inputs.end(); ++it)
55 { 55 {
56 LOG(INFO) << "Calling system command " << command_ << " on instance " << *it; 56 LOG(INFO) << "Calling system command " << command_ << " on instance " << *it;
57 57
58 std::string dicom; 58 try
59 context_.ReadFile(dicom, *it, FileContentType_Dicom); 59 {
60 std::string dicom;
61 context_.ReadFile(dicom, *it, FileContentType_Dicom);
60 62
61 Toolbox::TemporaryFile tmp; 63 Toolbox::TemporaryFile tmp;
62 tmp.Write(dicom); 64 tmp.Write(dicom);
63 65
64 std::vector<std::string> args = arguments_; 66 std::vector<std::string> args = arguments_;
65 args.push_back(tmp.GetPath()); 67 args.push_back(tmp.GetPath());
66 68
67 Toolbox::ExecuteSystemCommand(command_, args); 69 Toolbox::ExecuteSystemCommand(command_, args);
70
71 // Only chain with other commands if this command succeeds
72 outputs.push_back(*it);
73 }
74 catch (OrthancException& e)
75 {
76 LOG(ERROR) << "Unable to call system command " << command_
77 << " on instance " << *it << " in a Lua script: " << e.What();
78 }
68 } 79 }
69 80
70 return true; 81 return true;
71 } 82 }
72 } 83 }