OpendTect  6.6
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
OS::CommandLauncher Class Reference

Launches machine commands. More...

Public Member Functions

 CommandLauncher (const MachineCommand &)
 
 ~CommandLauncher ()
 
uiString errorMsg () const
 
bool execute (BufferString &output_stdout, BufferString *output_stderr=nullptr, const char *workdir=nullptr)
 run &, wait until finished, catch output More...
 
bool execute (const CommandExecPars &)
 
bool execute (LaunchType lt=Wait4Finish, const char *workdir=nullptr)
 
od_istreamgetStdError ()
 
od_ostreamgetStdInput ()
 
od_istreamgetStdOutput ()
 
const char * monitorFileName () const
 
PID_Type processID () const
 
void set (const MachineCommand &)
 
bool startServer (bool inpythonenv, const char *stdoutfnm, const char *stderrfnm, double maxwaittm=20)
 
bool startServer (bool inpythonenv=false, double maxwaittm=20)
 

Static Public Member Functions

static void addQuotesIfNeeded (BufferString &cmd)
 
static void addShellIfNeeded (BufferString &cmd)
 
static void manageQProcess (QProcess *)
 
static bool openTerminal (const char *cmd, const BufferStringSet *args, BufferString *errmsg=nullptr, uiString *launchermsg=nullptr, const char *workdir=nullptr)
 
static bool openTerminal (const char *workdir)
 

Protected Member Functions

int catchError ()
 
bool doExecute (const MachineCommand &, const CommandExecPars &)
 
void reset ()
 
bool startDetached (const MachineCommand &, bool inconsole=false, const char *workingdir=nullptr)
 
void startMonitor ()
 

Protected Attributes

uiString errmsg_
 
MachineCommand machcmd_
 
BufferString monitorfnm_
 
const BufferString odprogressviewer_
 
PID_Type pid_
 
QProcess * process_
 
BufferString progvwrcmd_
 
bool redirectoutput_
 
od_istreamstderror_
 
qstreambufstderrorbuf_
 
od_ostreamstdinput_
 
qstreambufstdinputbuf_
 
od_istreamstdoutput_
 
qstreambufstdoutputbuf_
 

Private Member Functions

void adaptForV7 (const OS::MachineCommand &)
 
void setIsolated ()
 

Detailed Description

Launches machine commands.

<>

Constructor & Destructor Documentation

◆ CommandLauncher()

OS::CommandLauncher::CommandLauncher ( const MachineCommand )

◆ ~CommandLauncher()

OS::CommandLauncher::~CommandLauncher ( )

Member Function Documentation

◆ adaptForV7()

void OS::CommandLauncher::adaptForV7 ( const OS::MachineCommand )
private

◆ addQuotesIfNeeded()

static void OS::CommandLauncher::addQuotesIfNeeded ( BufferString cmd)
static

Checks for spaces in command, and surrounds command with quotes them if not already done.

◆ addShellIfNeeded()

static void OS::CommandLauncher::addShellIfNeeded ( BufferString cmd)
static

Analyses the cmd and looks for pipes or redirects. If these are found, the cmd is converted to a shell command.

◆ catchError()

int OS::CommandLauncher::catchError ( )
protected

◆ doExecute()

bool OS::CommandLauncher::doExecute ( const MachineCommand ,
const CommandExecPars  
)
protected

◆ errorMsg()

uiString OS::CommandLauncher::errorMsg ( ) const
inline

◆ execute() [1/3]

bool OS::CommandLauncher::execute ( BufferString output_stdout,
BufferString output_stderr = nullptr,
const char *  workdir = nullptr 
)

run &, wait until finished, catch output

◆ execute() [2/3]

bool OS::CommandLauncher::execute ( const CommandExecPars )

◆ execute() [3/3]

bool OS::CommandLauncher::execute ( LaunchType  lt = Wait4Finish,
const char *  workdir = nullptr 
)

◆ getStdError()

od_istream* OS::CommandLauncher::getStdError ( )
inline

◆ getStdInput()

od_ostream* OS::CommandLauncher::getStdInput ( )
inline

◆ getStdOutput()

od_istream* OS::CommandLauncher::getStdOutput ( )
inline

◆ manageQProcess()

static void OS::CommandLauncher::manageQProcess ( QProcess *  )
static

Add a QProcess and it will be deleted one day.

◆ monitorFileName()

const char* OS::CommandLauncher::monitorFileName ( ) const
inline

◆ openTerminal() [1/2]

static bool OS::CommandLauncher::openTerminal ( const char *  cmd,
const BufferStringSet args,
BufferString errmsg = nullptr,
uiString launchermsg = nullptr,
const char *  workdir = nullptr 
)
static

◆ openTerminal() [2/2]

static bool OS::CommandLauncher::openTerminal ( const char *  workdir)
static

◆ processID()

PID_Type OS::CommandLauncher::processID ( ) const

◆ reset()

void OS::CommandLauncher::reset ( )
protected

◆ set()

void OS::CommandLauncher::set ( const MachineCommand )

◆ setIsolated()

void OS::CommandLauncher::setIsolated ( )
private

◆ startDetached()

bool OS::CommandLauncher::startDetached ( const MachineCommand ,
bool  inconsole = false,
const char *  workingdir = nullptr 
)
protected

◆ startMonitor()

void OS::CommandLauncher::startMonitor ( )
protected

◆ startServer() [1/2]

bool OS::CommandLauncher::startServer ( bool  inpythonenv,
const char *  stdoutfnm,
const char *  stderrfnm,
double  maxwaittm = 20 
)

◆ startServer() [2/2]

bool OS::CommandLauncher::startServer ( bool  inpythonenv = false,
double  maxwaittm = 20 
)

Member Data Documentation

◆ errmsg_

uiString OS::CommandLauncher::errmsg_
protected

◆ machcmd_

MachineCommand OS::CommandLauncher::machcmd_
protected

◆ monitorfnm_

BufferString OS::CommandLauncher::monitorfnm_
protected

◆ odprogressviewer_

const BufferString OS::CommandLauncher::odprogressviewer_
protected

◆ pid_

PID_Type OS::CommandLauncher::pid_
protected

◆ process_

QProcess* OS::CommandLauncher::process_
protected

◆ progvwrcmd_

BufferString OS::CommandLauncher::progvwrcmd_
protected

◆ redirectoutput_

bool OS::CommandLauncher::redirectoutput_
protected

◆ stderror_

od_istream* OS::CommandLauncher::stderror_
protected

◆ stderrorbuf_

qstreambuf* OS::CommandLauncher::stderrorbuf_
protected

◆ stdinput_

od_ostream* OS::CommandLauncher::stdinput_
protected

◆ stdinputbuf_

qstreambuf* OS::CommandLauncher::stdinputbuf_
protected

◆ stdoutput_

od_istream* OS::CommandLauncher::stdoutput_
protected

◆ stdoutputbuf_

qstreambuf* OS::CommandLauncher::stdoutputbuf_
protected

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2022