From 76b108d068b362e24bbb9547269a0945f206a0bb Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 24 Feb 2020 11:45:21 +0100 Subject: [PATCH] Fix import of well paths and well log files from Python when the folder is not provided --- .../RicfImportWellLogFiles.cpp | 22 +++++++++-- .../WellPathCommands/RicImportWellPaths.cpp | 37 +++++++++++++------ 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/CommandFileInterface/RicfImportWellLogFiles.cpp b/ApplicationCode/CommandFileInterface/RicfImportWellLogFiles.cpp index 9d6f3bc8b2..664ec38f2e 100644 --- a/ApplicationCode/CommandFileInterface/RicfImportWellLogFiles.cpp +++ b/ApplicationCode/CommandFileInterface/RicfImportWellLogFiles.cpp @@ -19,6 +19,7 @@ #include "WellLogCommands/RicWellLogsImportFileFeature.h" +#include "RiaApplication.h" #include "RimWellLogFile.h" #include @@ -52,15 +53,24 @@ RicfCommandResponse RicfImportWellLogFiles::execute() QStringList errorMessages, warningMessages; QStringList wellLogFilePaths; - QDir wellPathFolder( m_wellLogFileFolder ); - if ( wellPathFolder.exists() ) + QDir wellLogDir; + if ( m_wellLogFileFolder().isEmpty() ) + { + wellLogDir = QDir( RiaApplication::instance()->startDir() ); + } + else + { + wellLogDir = QDir( m_wellLogFileFolder ); + } + + if ( !m_wellLogFileFolder().isEmpty() ) { QStringList nameFilters; nameFilters << RicWellLogsImportFileFeature::wellLogFileNameFilters(); - QStringList relativePaths = wellPathFolder.entryList( nameFilters, QDir::Files | QDir::NoDotAndDotDot ); + QStringList relativePaths = wellLogDir.entryList( nameFilters, QDir::Files | QDir::NoDotAndDotDot ); for ( QString relativePath : relativePaths ) { - wellLogFilePaths.push_back( wellPathFolder.absoluteFilePath( relativePath ) ); + wellLogFilePaths.push_back( wellLogDir.absoluteFilePath( relativePath ) ); } } else @@ -74,6 +84,10 @@ RicfCommandResponse RicfImportWellLogFiles::execute() { wellLogFilePaths.push_back( wellLogFilePath ); } + else if ( QFileInfo::exists( wellLogDir.absoluteFilePath( wellLogFilePath ) ) ) + { + wellLogFilePaths.push_back( wellLogDir.absoluteFilePath( wellLogFilePath ) ); + } else { errorMessages << ( wellLogFilePath + " doesn't exist" ); diff --git a/ApplicationCode/Commands/WellPathCommands/RicImportWellPaths.cpp b/ApplicationCode/Commands/WellPathCommands/RicImportWellPaths.cpp index 53e8d0685e..205569b44a 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicImportWellPaths.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicImportWellPaths.cpp @@ -71,21 +71,32 @@ RicfCommandResponse RicImportWellPaths::execute() QStringList errorMessages, warningMessages; QStringList wellPathFiles; - QDir wellPathFolder( m_wellPathFolder ); - - if ( wellPathFolder.exists() ) + QDir wellPathDir; + if ( m_wellPathFolder().isEmpty() ) { - QStringList nameFilters; - nameFilters << RicImportWellPaths::wellPathNameFilters(); - QStringList relativePaths = wellPathFolder.entryList( nameFilters, QDir::Files | QDir::NoDotAndDotDot ); - for ( QString relativePath : relativePaths ) - { - wellPathFiles.push_back( wellPathFolder.absoluteFilePath( relativePath ) ); - } + wellPathDir = QDir( RiaApplication::instance()->startDir() ); } else { - errorMessages << ( m_wellPathFolder() + " does not exist" ); + wellPathDir = QDir( m_wellPathFolder ); + } + + if ( !m_wellPathFolder().isEmpty() ) + { + if ( wellPathDir.exists() ) + { + QStringList nameFilters; + nameFilters << RicImportWellPaths::wellPathNameFilters(); + QStringList relativePaths = wellPathDir.entryList( nameFilters, QDir::Files | QDir::NoDotAndDotDot ); + for ( QString relativePath : relativePaths ) + { + wellPathFiles.push_back( wellPathDir.absoluteFilePath( relativePath ) ); + } + } + else + { + errorMessages << ( wellPathDir.absolutePath() + " does not exist" ); + } } for ( QString wellPathFile : m_wellPathFiles() ) @@ -94,6 +105,10 @@ RicfCommandResponse RicImportWellPaths::execute() { wellPathFiles.push_back( wellPathFile ); } + else if ( QFileInfo::exists( wellPathDir.absoluteFilePath( wellPathFile ) ) ) + { + wellPathFiles.push_back( wellPathDir.absoluteFilePath( wellPathFile ) ); + } else { errorMessages << ( wellPathFile + " does not exist" );