GUI: Print and log messages when addon execution fails (#2408)

This adds an entry to the "Analysis Log" and prints a message via
`qWarning()` when the execution of an addon fails because either the
process failed to finish normally (for example if python binary is not
found) or because the script has issues (for example because of an
unhandled exception).
This commit is contained in:
Sebastian 2019-11-30 12:58:06 +01:00 committed by GitHub
parent 8d114a40e4
commit 95bbc7a1e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -313,7 +313,22 @@ void CheckThread::runAddonsAndTools(const ImportProject::FileSettings *fileSetti
process.setProcessEnvironment(env); process.setProcessEnvironment(env);
} }
process.start(python, args); process.start(python, args);
process.waitForFinished(); if (!process.waitForFinished()) {
const QString errMsg("ERROR: Process '" + python + " " + args.join(" ") +
"' did not finish successfully: " + process.errorString());
qWarning() << errMsg;
mResult.reportOut(errMsg.toStdString());
}
const QByteArray errout = process.readAllStandardError();
if (process.exitCode() != 0 && !errout.isEmpty()) {
const QString errMsg("ERROR: Process '" + python + " " + args.join(" ") +
"' failed with error code " +
QString::number(process.exitCode()) + ": '" +
process.errorString() +
"'\nError output: " + errout);
qWarning() << errMsg;
mResult.reportOut(errMsg.toStdString());
}
const QString output(process.readAllStandardOutput()); const QString output(process.readAllStandardOutput());
QFile f(dumpFile + '-' + addon + "-results"); QFile f(dumpFile + '-' + addon + "-results");
if (f.open(QIODevice::WriteOnly | QIODevice::Text)) { if (f.open(QIODevice::WriteOnly | QIODevice::Text)) {