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:
@@ -105,6 +105,7 @@ RiaPreferences::RiaPreferences(void)
|
|||||||
CAF_PDM_InitField(&pythonExecutable, "pythonExecutable", QString("python"), "Python Executable Location", "", "", "");
|
CAF_PDM_InitField(&pythonExecutable, "pythonExecutable", QString("python"), "Python Executable Location", "", "", "");
|
||||||
pythonExecutable.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
pythonExecutable.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||||
pythonExecutable.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
|
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", "", "", "");
|
CAF_PDM_InitField(&ssihubAddress, "ssihubAddress", QString("http://"), "SSIHUB Address", "", "", "");
|
||||||
ssihubAddress.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
|
ssihubAddress.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
|
||||||
@@ -318,8 +319,9 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
|
|||||||
#ifdef ENABLE_GRPC
|
#ifdef ENABLE_GRPC
|
||||||
caf::PdmUiGroup* pythonGroup = uiOrdering.addNewGroup("Python");
|
caf::PdmUiGroup* pythonGroup = uiOrdering.addNewGroup("Python");
|
||||||
pythonGroup->add(&enableGrpcServer);
|
pythonGroup->add(&enableGrpcServer);
|
||||||
|
pythonGroup->add(&showPythonDebugInfo);
|
||||||
pythonGroup->add(&defaultGrpcPortNumber);
|
pythonGroup->add(&defaultGrpcPortNumber);
|
||||||
pythonGroup->add(&pythonExecutable);
|
pythonGroup->add(&pythonExecutable);
|
||||||
#endif
|
#endif
|
||||||
caf::PdmUiGroup* scriptGroup = uiOrdering.addNewGroup("Script files");
|
caf::PdmUiGroup* scriptGroup = uiOrdering.addNewGroup("Script files");
|
||||||
scriptGroup->add(&scriptDirectories);
|
scriptGroup->add(&scriptDirectories);
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ public: // Pdm Fields
|
|||||||
caf::PdmField<bool> octaveShowHeaderInfoWhenExecutingScripts;
|
caf::PdmField<bool> octaveShowHeaderInfoWhenExecutingScripts;
|
||||||
|
|
||||||
caf::PdmField<QString> pythonExecutable;
|
caf::PdmField<QString> pythonExecutable;
|
||||||
|
caf::PdmField<bool> showPythonDebugInfo;
|
||||||
|
|
||||||
caf::PdmField<QString> ssihubAddress;
|
caf::PdmField<QString> ssihubAddress;
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,12 @@
|
|||||||
|
|
||||||
#include "RicScriptFeatureImpl.h"
|
#include "RicScriptFeatureImpl.h"
|
||||||
|
|
||||||
#include "RimCalcScript.h"
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
#include "RiaPreferences.h"
|
||||||
|
#include "RimCalcScript.h"
|
||||||
#include "RiuMainWindow.h"
|
#include "RiuMainWindow.h"
|
||||||
|
#include "RiuProcessMonitor.h"
|
||||||
|
|
||||||
#include "cafSelectionManager.h"
|
#include "cafSelectionManager.h"
|
||||||
#include "cvfAssert.h"
|
#include "cvfAssert.h"
|
||||||
@@ -31,6 +34,8 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
CAF_CMD_SOURCE_INIT(RicExecuteScriptFeature, "RicExecuteScriptFeature");
|
CAF_CMD_SOURCE_INIT(RicExecuteScriptFeature, "RicExecuteScriptFeature");
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -71,7 +76,35 @@ void RicExecuteScriptFeature::onActionTriggered(bool isChecked)
|
|||||||
if (!pythonPath.isEmpty())
|
if (!pythonPath.isEmpty())
|
||||||
{
|
{
|
||||||
QStringList arguments = RimCalcScript::createCommandLineArguments(calcScript->absoluteFileName());
|
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