Mercurial > hg > orthanc
diff 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 |
line wrap: on
line diff
--- a/OrthancServer/Scheduler/CallSystemCommand.cpp Tue Aug 05 16:18:45 2014 +0200 +++ b/OrthancServer/Scheduler/CallSystemCommand.cpp Thu Aug 07 10:02:22 2014 +0200 @@ -55,16 +55,27 @@ { LOG(INFO) << "Calling system command " << command_ << " on instance " << *it; - std::string dicom; - context_.ReadFile(dicom, *it, FileContentType_Dicom); + try + { + std::string dicom; + context_.ReadFile(dicom, *it, FileContentType_Dicom); + + Toolbox::TemporaryFile tmp; + tmp.Write(dicom); + + std::vector<std::string> args = arguments_; + args.push_back(tmp.GetPath()); - Toolbox::TemporaryFile tmp; - tmp.Write(dicom); + Toolbox::ExecuteSystemCommand(command_, args); - std::vector<std::string> args = arguments_; - args.push_back(tmp.GetPath()); - - Toolbox::ExecuteSystemCommand(command_, args); + // Only chain with other commands if this command succeeds + outputs.push_back(*it); + } + catch (OrthancException& e) + { + LOG(ERROR) << "Unable to call system command " << command_ + << " on instance " << *it << " in a Lua script: " << e.What(); + } } return true;