| 67 | } |
| 68 | |
| 69 | bool RWrapper::findR( const QString& executable /*= "Rscript"*/, bool verbose /*= true*/ ) |
| 70 | { |
| 71 | if (verbose) OPENMS_LOG_INFO << "Finding R interpreter 'Rscript' ..."; |
| 72 | |
| 73 | QStringList args(QStringList() << "--vanilla" << "-e" << "sessionInfo()"); |
| 74 | QProcess p; |
| 75 | p.setProcessChannelMode(QProcess::MergedChannels); // stdout receives all messages (stderr is empty) |
| 76 | p.start(executable, args); |
| 77 | p.waitForFinished(-1); |
| 78 | |
| 79 | if (p.error() == QProcess::FailedToStart) |
| 80 | { |
| 81 | if (verbose) |
| 82 | { |
| 83 | OPENMS_LOG_INFO << " failed" << std::endl; |
| 84 | String out = QString(p.readAllStandardOutput()).toStdString(); |
| 85 | OPENMS_LOG_ERROR << "Error: Could not find or run '" << executable.toStdString() << "' executable (FailedToStart).\n"; |
| 86 | if (!out.empty()) |
| 87 | { |
| 88 | OPENMS_LOG_ERROR << "Output was:\n------>\n" |
| 89 | << out |
| 90 | << "\n<------\n"; |
| 91 | } |
| 92 | OPENMS_LOG_ERROR << "Please install 'Rscript', make sure it's in PATH and is flagged as executable." << std::endl; |
| 93 | } |
| 94 | |
| 95 | return false; |
| 96 | } |
| 97 | if (verbose) |
| 98 | { |
| 99 | OPENMS_LOG_INFO << " success" << std::endl; |
| 100 | } |
| 101 | if (verbose) |
| 102 | { |
| 103 | OPENMS_LOG_INFO << "Trying to invoke 'Rscript' ..."; |
| 104 | } |
| 105 | if (p.exitStatus() != QProcess::NormalExit || p.exitCode() != 0) |
| 106 | { |
| 107 | if (verbose) |
| 108 | { |
| 109 | OPENMS_LOG_INFO << " failed" << std::endl; |
| 110 | OPENMS_LOG_ERROR << "Error: 'Rscript' executable returned with error (command: 'Rscript " << args.join(" ").toStdString() << "')\n" |
| 111 | << "Output was:\n------>\n" |
| 112 | << QString(p.readAllStandardOutput()).toStdString() |
| 113 | << "\n<------\n" |
| 114 | << "Make sure 'Rscript' is installed properly." << std::endl; |
| 115 | } |
| 116 | return false; |
| 117 | } |
| 118 | if (verbose) |
| 119 | { |
| 120 | OPENMS_LOG_INFO << " success" << std::endl; |
| 121 | } |
| 122 | return true; |
| 123 | } |
| 124 | |
| 125 | OpenMS::String RWrapper::findScript( const String& script_file, bool verbose /*= true*/ ) |
| 126 | { |
nothing calls this directly
no test coverage detected