mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-14 17:44:20 -06:00
#4626 Add support for printing debug info for Python
This commit is contained in:
parent
1aafed74e3
commit
48a4b18289
@ -105,6 +105,7 @@ RiaPreferences::RiaPreferences(void)
|
||||
CAF_PDM_InitField(&pythonExecutable, "pythonExecutable", QString("python"), "Python Executable Location", "", "", "");
|
||||
pythonExecutable.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
pythonExecutable.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
|
||||
CAF_PDM_InitField(&showPythonDebugInfo, "pythonDebugInfo", false, "Show Python Debug Info", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&ssihubAddress, "ssihubAddress", QString("http://"), "SSIHUB Address", "", "", "");
|
||||
ssihubAddress.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
|
||||
@ -318,8 +319,9 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
|
||||
#ifdef ENABLE_GRPC
|
||||
caf::PdmUiGroup* pythonGroup = uiOrdering.addNewGroup("Python");
|
||||
pythonGroup->add(&enableGrpcServer);
|
||||
pythonGroup->add(&showPythonDebugInfo);
|
||||
pythonGroup->add(&defaultGrpcPortNumber);
|
||||
pythonGroup->add(&pythonExecutable);
|
||||
pythonGroup->add(&pythonExecutable);
|
||||
#endif
|
||||
caf::PdmUiGroup* scriptGroup = uiOrdering.addNewGroup("Script files");
|
||||
scriptGroup->add(&scriptDirectories);
|
||||
|
@ -89,6 +89,7 @@ public: // Pdm Fields
|
||||
caf::PdmField<bool> octaveShowHeaderInfoWhenExecutingScripts;
|
||||
|
||||
caf::PdmField<QString> pythonExecutable;
|
||||
caf::PdmField<bool> showPythonDebugInfo;
|
||||
|
||||
caf::PdmField<QString> ssihubAddress;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user