2021-05-18 14:28:54 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2021 - Equinor ASA
|
|
|
|
|
//
|
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "RimProcess.h"
|
|
|
|
|
|
|
|
|
|
#include "RiaLogging.h"
|
2026-09-16 18:41:26 +02:00
|
|
|
#include "RiaPreferencesOpm.h"
|
2026-05-06 12:00:10 +02:00
|
|
|
#include "RiaQStringFormatter.h"
|
2026-09-16 18:41:26 +02:00
|
|
|
#include "RiaWslTools.h"
|
2021-05-18 14:28:54 +02:00
|
|
|
#include "RimProcessMonitor.h"
|
|
|
|
|
|
|
|
|
|
#include "cafPdmFieldCapability.h"
|
|
|
|
|
|
2024-03-07 19:45:43 +01:00
|
|
|
#include <QApplication>
|
2021-05-18 14:28:54 +02:00
|
|
|
#include <QProcess>
|
2023-04-27 01:32:59 +02:00
|
|
|
#include <QProcessEnvironment>
|
2021-05-18 14:28:54 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT( RimProcess, "RimProcess" );
|
|
|
|
|
|
2026-04-17 19:55:50 +02:00
|
|
|
size_t RimProcess::m_nextProcessId = 1;
|
2021-05-18 14:28:54 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2026-09-16 18:41:26 +02:00
|
|
|
RimProcess::RimProcess( bool logStdOutErr, std::shared_ptr<RimProcessMonitor> monitor )
|
2025-06-11 15:43:53 +02:00
|
|
|
: m_enableLogging( logStdOutErr )
|
2025-10-18 02:42:11 +02:00
|
|
|
, m_qProcess( nullptr )
|
2021-05-18 14:28:54 +02:00
|
|
|
{
|
2026-04-17 19:55:50 +02:00
|
|
|
size_t defId = m_nextProcessId++;
|
2025-10-18 02:42:11 +02:00
|
|
|
if ( monitor == nullptr )
|
2026-09-16 18:41:26 +02:00
|
|
|
m_monitor = std::make_shared<RimProcessMonitor>( defId, logStdOutErr );
|
2025-10-18 02:42:11 +02:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_monitor = monitor;
|
|
|
|
|
m_monitor->setProcessId( defId );
|
|
|
|
|
}
|
2021-05-18 14:28:54 +02:00
|
|
|
|
2022-01-07 08:31:52 +01:00
|
|
|
CAF_PDM_InitObject( "ResInsight Process", ":/Erase.png" );
|
2021-05-18 14:28:54 +02:00
|
|
|
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_command, "Command", "Command" );
|
2021-05-18 14:28:54 +02:00
|
|
|
m_command.uiCapability()->setUiReadOnly( true );
|
|
|
|
|
|
2026-03-06 14:54:44 +01:00
|
|
|
CAF_PDM_InitField( &m_workDir, "WorkDir", caf::FilePath(), "Working Directory" );
|
2025-06-11 15:43:53 +02:00
|
|
|
m_command.uiCapability()->setUiReadOnly( true );
|
|
|
|
|
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_description, "Description", "Description" );
|
2021-05-18 14:28:54 +02:00
|
|
|
m_description.uiCapability()->setUiReadOnly( true );
|
|
|
|
|
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitField( &m_id, "ID", defId, "ID" );
|
2021-05-18 14:28:54 +02:00
|
|
|
m_id.uiCapability()->setUiReadOnly( true );
|
2026-09-16 18:41:26 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_InitField( &m_useWsl, "UseWSL", false, "Use WSL to launch process" );
|
|
|
|
|
m_useWsl.uiCapability()->setUiReadOnly( true );
|
2021-05-18 14:28:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProcess::~RimProcess()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
caf::PdmFieldHandle* RimProcess::userDescriptionField()
|
|
|
|
|
{
|
|
|
|
|
return &m_description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProcess::addParameter( QString paramStr )
|
|
|
|
|
{
|
|
|
|
|
m_arguments << paramStr.trimmed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-10-15 00:34:51 +02:00
|
|
|
void RimProcess::addParameters( QStringList parameterList )
|
2021-05-18 14:28:54 +02:00
|
|
|
{
|
|
|
|
|
for ( int i = 0; i < parameterList.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
addParameter( parameterList[i] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProcess::setCommand( QString cmdStr )
|
|
|
|
|
{
|
2024-10-15 00:34:51 +02:00
|
|
|
m_command = cmdStr.trimmed();
|
|
|
|
|
|
|
|
|
|
QString shell = optionalCommandInterpreter();
|
|
|
|
|
if ( shell.isEmpty() ) return;
|
|
|
|
|
|
|
|
|
|
QString preParam = optionalPreParameters();
|
|
|
|
|
if ( !preParam.isEmpty() ) m_arguments.append( preParam );
|
|
|
|
|
|
|
|
|
|
m_arguments.append( cmdStr.trimmed() );
|
|
|
|
|
m_command = shell;
|
2021-05-18 14:28:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProcess::setDescription( QString desc )
|
|
|
|
|
{
|
|
|
|
|
m_description = desc;
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-16 18:41:26 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimProcess::description() const
|
|
|
|
|
{
|
|
|
|
|
return m_description();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::shared_ptr<RimProcessMonitor> RimProcess::monitor() const
|
|
|
|
|
{
|
|
|
|
|
return m_monitor;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-18 14:28:54 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimProcess::command() const
|
|
|
|
|
{
|
2026-09-16 18:41:26 +02:00
|
|
|
return m_command();
|
2021-05-18 14:28:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QStringList RimProcess::parameters() const
|
|
|
|
|
{
|
|
|
|
|
return m_arguments;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-11 15:43:53 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2026-09-16 18:41:26 +02:00
|
|
|
const QStringList& RimProcess::stdOut() const
|
2025-06-11 15:43:53 +02:00
|
|
|
{
|
|
|
|
|
if ( m_monitor ) return m_monitor->stdOut();
|
2026-09-16 18:41:26 +02:00
|
|
|
return m_emptyList;
|
2025-06-11 15:43:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2026-09-16 18:41:26 +02:00
|
|
|
const QStringList& RimProcess::stdErr() const
|
2025-06-11 15:43:53 +02:00
|
|
|
{
|
|
|
|
|
if ( m_monitor ) return m_monitor->stdErr();
|
2026-09-16 18:41:26 +02:00
|
|
|
return m_emptyList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProcess::appendStdOut( QString line )
|
|
|
|
|
{
|
|
|
|
|
if ( m_monitor ) m_monitor->appendStdOut( line );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProcess::appendStdErr( QString line )
|
|
|
|
|
{
|
|
|
|
|
if ( m_monitor ) m_monitor->appendStdErr( line );
|
2025-06-11 15:43:53 +02:00
|
|
|
}
|
|
|
|
|
|
2021-05-18 14:28:54 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2026-04-17 19:55:50 +02:00
|
|
|
size_t RimProcess::ID() const
|
2021-05-18 14:28:54 +02:00
|
|
|
{
|
2026-04-17 19:55:50 +02:00
|
|
|
return m_id();
|
2021-05-18 14:28:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-10-18 02:42:11 +02:00
|
|
|
bool RimProcess::start( bool enableStdOut, bool enableStdErr )
|
2021-05-18 14:28:54 +02:00
|
|
|
{
|
2025-06-11 15:43:53 +02:00
|
|
|
if ( !m_monitor ) return false;
|
2025-10-18 02:42:11 +02:00
|
|
|
if ( m_qProcess != nullptr ) return false;
|
2025-06-11 15:43:53 +02:00
|
|
|
|
2025-10-18 02:42:11 +02:00
|
|
|
m_qProcess = new QProcess();
|
|
|
|
|
QString cmd = commandLine();
|
2021-05-18 14:28:54 +02:00
|
|
|
|
2026-09-16 18:41:26 +02:00
|
|
|
if ( m_enableLogging )
|
|
|
|
|
{
|
|
|
|
|
std::string wslTxt = m_useWsl() ? " using WSL" : "";
|
|
|
|
|
RiaLogging::info( std::format( "Start process {}{}: {}", m_id(), wslTxt, cmd ) );
|
|
|
|
|
}
|
2025-06-11 15:43:53 +02:00
|
|
|
|
|
|
|
|
m_monitor->clearStdOutErr();
|
2021-05-18 14:28:54 +02:00
|
|
|
|
2026-09-16 18:41:26 +02:00
|
|
|
QObject::connect( m_qProcess, SIGNAL( finished( int, QProcess::ExitStatus ) ), m_monitor.get(), SLOT( finished( int, QProcess::ExitStatus ) ) );
|
|
|
|
|
if ( enableStdOut )
|
|
|
|
|
QObject::connect( m_qProcess, SIGNAL( readyReadStandardOutput() ), m_monitor.get(), SLOT( readyReadStandardOutput() ) );
|
|
|
|
|
if ( enableStdErr )
|
|
|
|
|
QObject::connect( m_qProcess, SIGNAL( readyReadStandardError() ), m_monitor.get(), SLOT( readyReadStandardError() ) );
|
|
|
|
|
QObject::connect( m_qProcess, SIGNAL( started() ), m_monitor.get(), SLOT( started() ) );
|
2023-04-27 01:32:59 +02:00
|
|
|
|
|
|
|
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
|
|
|
|
for ( auto& [key, val] : m_environmentVariables )
|
|
|
|
|
{
|
|
|
|
|
env.insert( key, val );
|
|
|
|
|
}
|
2025-10-18 02:42:11 +02:00
|
|
|
m_qProcess->setProcessEnvironment( env );
|
2026-03-06 14:54:44 +01:00
|
|
|
if ( !m_workDir().path().isEmpty() )
|
2025-06-11 15:43:53 +02:00
|
|
|
{
|
2026-03-06 14:54:44 +01:00
|
|
|
m_qProcess->setWorkingDirectory( m_workDir().path() );
|
2025-10-18 02:42:11 +02:00
|
|
|
}
|
|
|
|
|
|
2026-09-16 18:41:26 +02:00
|
|
|
if ( m_useWsl() )
|
|
|
|
|
{
|
|
|
|
|
m_arguments.prepend( m_command() );
|
|
|
|
|
m_arguments = RiaPreferencesOpm::current()->wslOptions() + m_arguments;
|
|
|
|
|
m_command = RiaWslTools::wslCommand();
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-18 02:42:11 +02:00
|
|
|
m_qProcess->start( m_command, m_arguments );
|
|
|
|
|
if ( !m_qProcess->waitForStarted( -1 ) )
|
|
|
|
|
{
|
2026-09-16 18:41:26 +02:00
|
|
|
if ( m_enableLogging )
|
|
|
|
|
{
|
|
|
|
|
auto error = m_qProcess->errorString();
|
|
|
|
|
RiaLogging::error( std::format( "Failed to start process {}. {}.", m_id(), error ) );
|
|
|
|
|
}
|
2025-10-18 02:42:11 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-16 18:41:26 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProcess::writeToStdIn( QStringList text )
|
|
|
|
|
{
|
|
|
|
|
if ( m_qProcess == nullptr ) return;
|
|
|
|
|
|
|
|
|
|
for ( auto& line : text )
|
|
|
|
|
{
|
|
|
|
|
m_qProcess->write( line.toUtf8() + "\n" );
|
|
|
|
|
m_qProcess->waitForBytesWritten();
|
|
|
|
|
m_qProcess->closeWriteChannel();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-18 02:42:11 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProcess::cleanUpAfterRun()
|
|
|
|
|
{
|
|
|
|
|
if ( m_qProcess != nullptr )
|
|
|
|
|
{
|
|
|
|
|
m_qProcess->deleteLater();
|
|
|
|
|
m_qProcess = nullptr;
|
2025-06-11 15:43:53 +02:00
|
|
|
}
|
2025-10-18 02:42:11 +02:00
|
|
|
}
|
2023-04-27 01:32:59 +02:00
|
|
|
|
2025-10-18 02:42:11 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProcess::terminate()
|
|
|
|
|
{
|
|
|
|
|
if ( m_qProcess != nullptr )
|
2021-05-18 14:28:54 +02:00
|
|
|
{
|
2025-10-18 02:42:11 +02:00
|
|
|
if ( m_qProcess->state() == QProcess::Running )
|
2021-05-18 14:28:54 +02:00
|
|
|
{
|
2025-10-18 02:42:11 +02:00
|
|
|
m_qProcess->kill();
|
2021-05-18 14:28:54 +02:00
|
|
|
}
|
|
|
|
|
}
|
2025-10-18 02:42:11 +02:00
|
|
|
}
|
|
|
|
|
|
2026-04-17 19:55:50 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProcess::notifyErrorFinish()
|
|
|
|
|
{
|
|
|
|
|
if ( m_monitor ) m_monitor->finished( -1, QProcess::CrashExit );
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-18 02:42:11 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RimProcess::execute( bool enableStdOut, bool enableStdErr )
|
|
|
|
|
{
|
|
|
|
|
if ( !start( enableStdOut, enableStdErr ) ) return false;
|
|
|
|
|
|
|
|
|
|
while ( !m_qProcess->waitForFinished( 250 ) )
|
2021-05-18 14:28:54 +02:00
|
|
|
{
|
2025-10-18 02:42:11 +02:00
|
|
|
QApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
|
2021-05-18 14:28:54 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-18 02:42:11 +02:00
|
|
|
bool retval = ( m_qProcess->exitCode() == 0 );
|
|
|
|
|
|
|
|
|
|
cleanUpAfterRun();
|
2021-05-18 14:28:54 +02:00
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-05-20 14:35:29 +02:00
|
|
|
QString RimProcess::optionalCommandInterpreter() const
|
2021-05-18 14:28:54 +02:00
|
|
|
{
|
2021-05-20 14:35:29 +02:00
|
|
|
if ( m_command.value().isNull() ) return "";
|
|
|
|
|
|
2024-10-15 00:34:51 +02:00
|
|
|
if ( isWindowsBatchFile() )
|
2021-05-20 14:35:29 +02:00
|
|
|
{
|
2024-10-15 00:34:51 +02:00
|
|
|
return "cmd.exe";
|
2021-05-20 14:35:29 +02:00
|
|
|
}
|
|
|
|
|
if ( m_command.value().endsWith( ".sh", Qt::CaseInsensitive ) )
|
|
|
|
|
{
|
2024-10-15 00:34:51 +02:00
|
|
|
return "bash";
|
2021-05-20 14:35:29 +02:00
|
|
|
}
|
|
|
|
|
if ( m_command.value().endsWith( ".csh", Qt::CaseInsensitive ) )
|
|
|
|
|
{
|
2024-10-15 00:34:51 +02:00
|
|
|
return "csh";
|
2021-05-20 14:35:29 +02:00
|
|
|
}
|
|
|
|
|
return "";
|
2021-05-18 14:28:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-10-15 00:34:51 +02:00
|
|
|
QString RimProcess::optionalPreParameters() const
|
2021-05-18 14:28:54 +02:00
|
|
|
{
|
2024-10-15 00:34:51 +02:00
|
|
|
if ( m_command.value().isNull() ) return "";
|
|
|
|
|
|
|
|
|
|
if ( isWindowsBatchFile() )
|
|
|
|
|
{
|
|
|
|
|
return "/c";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2021-05-18 14:28:54 +02:00
|
|
|
|
2024-10-15 00:34:51 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RimProcess::isWindowsBatchFile() const
|
|
|
|
|
{
|
|
|
|
|
return ( m_command.value().endsWith( ".cmd", Qt::CaseInsensitive ) || m_command.value().endsWith( ".bat", Qt::CaseInsensitive ) );
|
|
|
|
|
}
|
2021-05-18 14:28:54 +02:00
|
|
|
|
2024-10-15 00:34:51 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimProcess::commandLine() const
|
|
|
|
|
{
|
|
|
|
|
QString cmdline = handleSpaces( m_command );
|
2021-05-18 14:28:54 +02:00
|
|
|
|
|
|
|
|
for ( int i = 0; i < m_arguments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
cmdline += " ";
|
|
|
|
|
cmdline += handleSpaces( m_arguments[i] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return cmdline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimProcess::handleSpaces( QString arg ) const
|
|
|
|
|
{
|
|
|
|
|
if ( arg.contains( " " ) && !arg.startsWith( "\"" ) )
|
|
|
|
|
{
|
|
|
|
|
return QString( "\"" + arg + "\"" );
|
|
|
|
|
}
|
|
|
|
|
return arg;
|
|
|
|
|
}
|
2023-04-27 01:32:59 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProcess::addEnvironmentVariable( QString name, QString value )
|
|
|
|
|
{
|
|
|
|
|
m_environmentVariables.push_back( std::make_pair( name, value ) );
|
|
|
|
|
}
|
2025-06-11 15:43:53 +02:00
|
|
|
|
2026-09-16 18:41:26 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
const std::vector<std::pair<QString, QString>>& RimProcess::environmentVariables() const
|
|
|
|
|
{
|
|
|
|
|
return m_environmentVariables;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-11 15:43:53 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProcess::setWorkingDirectory( QString workDir )
|
|
|
|
|
{
|
|
|
|
|
m_workDir = workDir;
|
|
|
|
|
}
|
2026-09-16 18:41:26 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimProcess::workingDirectory() const
|
|
|
|
|
{
|
|
|
|
|
return m_workDir().path();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RimProcess::useWsl() const
|
|
|
|
|
{
|
|
|
|
|
return m_useWsl();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProcess::setUseWsl( bool useWsl )
|
|
|
|
|
{
|
|
|
|
|
m_useWsl = useWsl;
|
|
|
|
|
}
|