mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1665 Add error handling and logging to command file execution
This commit is contained in:
parent
ab1322c5d7
commit
d0564c4d2a
@ -21,6 +21,8 @@
|
|||||||
#include "RifcCommandFileReader.h"
|
#include "RifcCommandFileReader.h"
|
||||||
#include "RicfCommandObject.h"
|
#include "RicfCommandObject.h"
|
||||||
|
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
namespace caf {
|
namespace caf {
|
||||||
template<>
|
template<>
|
||||||
void RicfCommandFileExecutor::ExportTypeEnum::setUp()
|
void RicfCommandFileExecutor::ExportTypeEnum::setUp()
|
||||||
@ -55,7 +57,14 @@ void RicfCommandFileExecutor::executeCommands(QTextStream& stream)
|
|||||||
std::vector<RicfCommandObject*> commands = RicfCommandFileReader::readCommands(stream, caf::PdmDefaultObjectFactory::instance(), &m_messages);
|
std::vector<RicfCommandObject*> commands = RicfCommandFileReader::readCommands(stream, caf::PdmDefaultObjectFactory::instance(), &m_messages);
|
||||||
for (auto message : m_messages.m_messages)
|
for (auto message : m_messages.m_messages)
|
||||||
{
|
{
|
||||||
std::cout << message.second.toUtf8().constData();
|
if (message.first == RicfMessages::MESSAGE_WARNING)
|
||||||
|
{
|
||||||
|
RiaLogging::warning(message.second);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RiaLogging::error(message.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (RicfCommandObject* command : commands)
|
for (RicfCommandObject* command : commands)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include "RicfComputeCaseGroupStatistics.h"
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2017 Statoil ASA
|
// Copyright (C) 2017 Statoil ASA
|
||||||
@ -29,6 +28,7 @@
|
|||||||
#include "RimView.h"
|
#include "RimView.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT(RicfComputeCaseGroupStatistics, "computeCaseGroupStatistics");
|
CAF_PDM_SOURCE_INIT(RicfComputeCaseGroupStatistics, "computeCaseGroupStatistics");
|
||||||
|
|
||||||
@ -47,6 +47,7 @@ void RicfComputeCaseGroupStatistics::execute()
|
|||||||
{
|
{
|
||||||
for (int caseId : m_caseIds())
|
for (int caseId : m_caseIds())
|
||||||
{
|
{
|
||||||
|
bool foundCase = false;
|
||||||
for (RimIdenticalGridCaseGroup* group : RiaApplication::instance()->project()->activeOilField()->analysisModels()->caseGroups)
|
for (RimIdenticalGridCaseGroup* group : RiaApplication::instance()->project()->activeOilField()->analysisModels()->caseGroups)
|
||||||
{
|
{
|
||||||
for (RimEclipseCase* c : group->statisticsCaseCollection->reservoirs)
|
for (RimEclipseCase* c : group->statisticsCaseCollection->reservoirs)
|
||||||
@ -58,8 +59,21 @@ void RicfComputeCaseGroupStatistics::execute()
|
|||||||
{
|
{
|
||||||
statsCase->computeStatisticsAndUpdateViews();
|
statsCase->computeStatisticsAndUpdateViews();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RiaLogging::warning(QString("computeCaseGroupStatistics: Found case with ID %1, but it is not a statistics case, cannot compute statistics.").arg(caseId));
|
||||||
|
}
|
||||||
|
foundCase = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (foundCase) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundCase)
|
||||||
|
{
|
||||||
|
RiaLogging::warning(QString("computeCaseGroupStatistics: Could not find statistics case with ID %1.").arg(caseId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "RicfCommandFileExecutor.h"
|
#include "RicfCommandFileExecutor.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
#include "RimOilField.h"
|
#include "RimOilField.h"
|
||||||
@ -51,12 +52,22 @@ void RicfExportMsw::execute()
|
|||||||
{
|
{
|
||||||
RicCaseAndFileExportSettingsUi exportSettings;
|
RicCaseAndFileExportSettingsUi exportSettings;
|
||||||
|
|
||||||
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases())
|
|
||||||
{
|
{
|
||||||
if (c->caseId() == m_caseId())
|
bool foundCase = false;
|
||||||
|
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases())
|
||||||
{
|
{
|
||||||
exportSettings.caseToApply = c;
|
if (c->caseId() == m_caseId())
|
||||||
break;
|
{
|
||||||
|
exportSettings.caseToApply = c;
|
||||||
|
foundCase = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundCase)
|
||||||
|
{
|
||||||
|
RiaLogging::error(QString("exportMsw: Could not find case with ID %1.").arg(m_caseId()));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +79,11 @@ void RicfExportMsw::execute()
|
|||||||
exportSettings.folder = exportFolder;
|
exportSettings.folder = exportFolder;
|
||||||
|
|
||||||
RimWellPath* wellPath = RiaApplication::instance()->project()->activeOilField()->wellPathCollection->wellPathByName(m_wellPathName);
|
RimWellPath* wellPath = RiaApplication::instance()->project()->activeOilField()->wellPathCollection->wellPathByName(m_wellPathName);
|
||||||
|
if (!wellPath)
|
||||||
|
{
|
||||||
|
RiaLogging::error(QString("exportMsw: Could not find well path with name %1").arg(m_wellPathName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<RimFishbonesMultipleSubs*> fishbonesSubs;
|
std::vector<RimFishbonesMultipleSubs*> fishbonesSubs;
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include "RicfCommandFileExecutor.h"
|
#include "RicfCommandFileExecutor.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
#include "RimOilField.h"
|
#include "RimOilField.h"
|
||||||
#include "RimEclipseCaseCollection.h"
|
#include "RimEclipseCaseCollection.h"
|
||||||
@ -61,12 +63,21 @@ void RicfExportProperty::execute()
|
|||||||
|
|
||||||
RimEclipseCase* eclipseCase;
|
RimEclipseCase* eclipseCase;
|
||||||
|
|
||||||
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels()->cases)
|
|
||||||
{
|
{
|
||||||
if (c->caseId == m_caseId)
|
bool foundCase = false;
|
||||||
|
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels()->cases)
|
||||||
{
|
{
|
||||||
eclipseCase = c;
|
if (c->caseId == m_caseId)
|
||||||
break;
|
{
|
||||||
|
eclipseCase = c;
|
||||||
|
foundCase = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!foundCase)
|
||||||
|
{
|
||||||
|
RiaLogging::error(QString("exportProperty: Could not find case with ID %1").arg(m_caseId()));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +88,11 @@ void RicfExportProperty::execute()
|
|||||||
view = dynamic_cast<RimEclipseView*>(v);
|
view = dynamic_cast<RimEclipseView*>(v);
|
||||||
if (view) break;
|
if (view) break;
|
||||||
}
|
}
|
||||||
|
if (!view)
|
||||||
|
{
|
||||||
|
RiaLogging::error(QString("exportProperty: Could not find a view for case with ID %1").arg(m_caseId()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_eclipseKeyword().isNull())
|
if (m_eclipseKeyword().isNull())
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "RicfCommandFileExecutor.h"
|
#include "RicfCommandFileExecutor.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
#include "RimOilField.h"
|
#include "RimOilField.h"
|
||||||
@ -63,12 +64,21 @@ void RicfExportWellPathCompletions::execute()
|
|||||||
exportSettings.includeFishbones = m_includeFishbones;
|
exportSettings.includeFishbones = m_includeFishbones;
|
||||||
exportSettings.excludeMainBoreForFishbones = m_excludeMainBoreForFishbones;
|
exportSettings.excludeMainBoreForFishbones = m_excludeMainBoreForFishbones;
|
||||||
|
|
||||||
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases())
|
|
||||||
{
|
{
|
||||||
if (c->caseId() == m_caseId())
|
bool foundCase = false;
|
||||||
|
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases())
|
||||||
{
|
{
|
||||||
exportSettings.caseToApply = c;
|
if (c->caseId() == m_caseId())
|
||||||
break;
|
{
|
||||||
|
exportSettings.caseToApply = c;
|
||||||
|
foundCase = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!foundCase)
|
||||||
|
{
|
||||||
|
RiaLogging::error(QString("exportWellPathCompletions: Could not find case with ID %1").arg(m_caseId()));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "RicfLoadCase.h"
|
#include "RicfLoadCase.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT(RicfLoadCase, "loadCase");
|
CAF_PDM_SOURCE_INIT(RicfLoadCase, "loadCase");
|
||||||
|
|
||||||
@ -35,5 +36,9 @@ RicfLoadCase::RicfLoadCase()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicfLoadCase::execute()
|
void RicfLoadCase::execute()
|
||||||
{
|
{
|
||||||
RiaApplication::instance()->openEclipseCaseFromFile(m_path);
|
bool ok = RiaApplication::instance()->openEclipseCaseFromFile(m_path);
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
RiaLogging::error(QString("loadCase: Unable to load case from %1").arg(m_path()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "RicfOpenProject.h"
|
#include "RicfOpenProject.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT(RicfOpenProject, "openProject");
|
CAF_PDM_SOURCE_INIT(RicfOpenProject, "openProject");
|
||||||
|
|
||||||
@ -35,5 +36,9 @@ RicfOpenProject::RicfOpenProject()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicfOpenProject::execute()
|
void RicfOpenProject::execute()
|
||||||
{
|
{
|
||||||
RiaApplication::instance()->loadProject(m_path);
|
bool ok = RiaApplication::instance()->loadProject(m_path);
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
RiaLogging::error(QString("openProject: Unable to open project at %1").arg(m_path()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "RicfRunOctaveScript.h"
|
#include "RicfRunOctaveScript.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
@ -46,12 +47,17 @@ void RicfRunOctaveScript::execute()
|
|||||||
processArguments << "--path" << scriptFileInfo.absolutePath();
|
processArguments << "--path" << scriptFileInfo.absolutePath();
|
||||||
processArguments << scriptFileInfo.absoluteFilePath();
|
processArguments << scriptFileInfo.absoluteFilePath();
|
||||||
|
|
||||||
|
bool ok;
|
||||||
if (m_caseIds().empty())
|
if (m_caseIds().empty())
|
||||||
{
|
{
|
||||||
RiaApplication::instance()->launchProcess(octavePath, processArguments);
|
ok = RiaApplication::instance()->launchProcess(octavePath, processArguments);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RiaApplication::instance()->launchProcessForMultipleCases(octavePath, processArguments, m_caseIds());
|
ok = RiaApplication::instance()->launchProcessForMultipleCases(octavePath, processArguments, m_caseIds());
|
||||||
|
}
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
RiaLogging::error(QString("runOctaveScript: Could not execute script %1").arg(m_path()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "RimView.h"
|
#include "RimView.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT(RicfSetTimeStep, "setTimeStep");
|
CAF_PDM_SOURCE_INIT(RicfSetTimeStep, "setTimeStep");
|
||||||
|
|
||||||
@ -45,12 +46,21 @@ void RicfSetTimeStep::execute()
|
|||||||
{
|
{
|
||||||
RimEclipseCase* eclipseCase;
|
RimEclipseCase* eclipseCase;
|
||||||
|
|
||||||
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels()->cases)
|
|
||||||
{
|
{
|
||||||
if (c->caseId == m_caseId)
|
bool foundCase = false;
|
||||||
|
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels()->cases)
|
||||||
{
|
{
|
||||||
eclipseCase = c;
|
if (c->caseId == m_caseId)
|
||||||
break;
|
{
|
||||||
|
eclipseCase = c;
|
||||||
|
foundCase = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!foundCase)
|
||||||
|
{
|
||||||
|
RiaLogging::error(QString("setTimeStep: Could not find case with ID %1").arg(m_caseId()));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user