7#include <boost/process.hpp>
11namespace bp = boost::process;
18 std::string command,
DeviceModule& deviceModule, std::string outputName, std::string exitCodeName,
19 unsigned int errorGracePeriod)
21 _deviceAlias(deviceModule.getDeviceAliasOrURI()), _outputName(std::move(outputName)),
22 _exitCodeName(std::move(exitCodeName)), _errorGracePeriod(errorGracePeriod) {
28 std::string command,
DeviceModule& deviceModule, std::string outputName,
unsigned int errorGracePeriod)
29 :
ScriptedInitHandler(owner, name, description, std::move(command), deviceModule, std::move(outputName),
30 "initScriptExitCode", errorGracePeriod) {}
40 bp::child initScript(
_command, (bp::std_out & bp::std_err) > out);
46 while(std::getline(out, line)) {
47 output += line +
"\n";
55 output +=
"!!! " +
_deviceAlias +
" initialisation FAILED!";
62 throw ChimeraTK::runtime_error(
_deviceAlias +
" initialisation failed.");
69 catch(bp::process_error& e) {
71 throw ChimeraTK::logic_error(
"Caught boost::process::process_error while executing \"" +
_command +
void addInitialisationHandler(std::function< void(ChimeraTK::Device &)> initialisationHandler)
void setAndWrite(UserType newValue, VersionNumber versionNumber)=delete
InvalidityTracer application module.
Logger::StreamProxy logger(Logger::Severity severity, std::string context)
Convenience function to obtain the logger stream.
Initialisation handler which calls an external application (usually a script), captures its output (b...
unsigned int _errorGracePeriod
ScriptedInitHandler(ModuleGroup *owner, const std::string &name, const std::string &description, std::string command, DeviceModule &deviceModule, std::string outputName="initScriptOutput", std::string exitCodeName="initScriptExitCode", unsigned int errorGracePeriod=10)
Constructor.
ScalarOutput< std::string > _scriptOutput
ScalarOutput< int > _scriptExitCode