MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / runScript

Method runScript

src/openms/source/SYSTEM/RWrapper.cpp:20–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18{
19
20 bool RWrapper::runScript( const String& script_file, const QStringList& cmd_args, const QString& executable /*= "Rscript"*/, bool find_R /*= false */, bool verbose /*= true */)
21 {
22 if (find_R && !findR(executable, verbose))
23 {
24 return false;
25 }
26
27 String fullscript;
28 try
29 {
30 fullscript = findScript(script_file, verbose);
31 }
32 catch (...)
33 {
34 return false;
35 }
36
37 if (verbose)
38 {
39 OPENMS_LOG_INFO << "Running R script '" << fullscript << "' ...";
40 }
41 QStringList args;
42 args << "--vanilla" << "--quiet" << fullscript.toQString();
43 args.append(cmd_args);
44
45 QProcess p;
46 p.start(executable, args);
47 p.waitForFinished(-1);
48
49 if (p.error() == QProcess::FailedToStart || p.exitStatus() == QProcess::CrashExit || p.exitCode() != 0)
50 {
51 if (verbose)
52 {
53 OPENMS_LOG_INFO << " failed" << std::endl;
54 OPENMS_LOG_ERROR << "\n--- ERROR MESSAGES ---\n";
55 OPENMS_LOG_ERROR << QString(p.readAllStandardError()).toStdString();
56 OPENMS_LOG_ERROR << "\n--- OTHER MESSAGES ---\n";
57 OPENMS_LOG_ERROR << QString(p.readAllStandardOutput()).toStdString();
58 OPENMS_LOG_ERROR << "\n\nScript failed. See above for an error description. " << std::endl;
59 }
60 return false;
61 }
62 if (verbose)
63 {
64 OPENMS_LOG_INFO << " success" << std::endl;
65 }
66 return true;
67 }
68
69 bool RWrapper::findR( const QString& executable /*= "Rscript"*/, bool verbose /*= true*/ )
70 {

Callers

nothing calls this directly

Calls 5

QStringClass · 0.50
toQStringMethod · 0.45
appendMethod · 0.45
startMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected