mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4626 Add support for printing debug info for Python
This commit is contained in:
@@ -21,9 +21,12 @@
|
||||
|
||||
#include "RicScriptFeatureImpl.h"
|
||||
|
||||
#include "RimCalcScript.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RimCalcScript.h"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuProcessMonitor.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cvfAssert.h"
|
||||
@@ -31,6 +34,8 @@
|
||||
#include <QAction>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicExecuteScriptFeature, "RicExecuteScriptFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -71,7 +76,35 @@ void RicExecuteScriptFeature::onActionTriggered(bool isChecked)
|
||||
if (!pythonPath.isEmpty())
|
||||
{
|
||||
QStringList arguments = RimCalcScript::createCommandLineArguments(calcScript->absoluteFileName());
|
||||
RiaApplication::instance()->launchProcess(pythonPath, arguments, app->pythonProcessEnvironment());
|
||||
QProcessEnvironment penv = app->pythonProcessEnvironment();
|
||||
|
||||
RiuProcessMonitor* processMonitor = RiuMainWindow::instance()->processMonitor();
|
||||
if (RiaApplication::instance()->preferences()->showPythonDebugInfo() && processMonitor)
|
||||
{
|
||||
QStringList debugInfo;
|
||||
debugInfo << "----- Launching Python interpreter -----";
|
||||
debugInfo << "Python interpreter path: " + pythonPath;
|
||||
debugInfo << "Using arguments: ";
|
||||
for (QString argument : arguments)
|
||||
{
|
||||
debugInfo << "* " + argument;
|
||||
}
|
||||
QStringList envList = penv.toStringList();
|
||||
debugInfo << "Using environment: ";
|
||||
for (QString envVariable : envList)
|
||||
{
|
||||
debugInfo << "* " + envVariable;
|
||||
}
|
||||
|
||||
debugInfo << "------------------------------------";
|
||||
|
||||
for (QString debugString : debugInfo)
|
||||
{
|
||||
std::cout << debugString.toStdString() << std::endl;
|
||||
processMonitor->addStringToLog(debugString + "\n");
|
||||
}
|
||||
}
|
||||
RiaApplication::instance()->launchProcess(pythonPath, arguments, penv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user