21 #ifndef QGSRUNPROCESS_H
22 #define QGSRUNPROCESS_H
25 #if QT_CONFIG(process)
31 #include "qgis_core.h"
71 static QStringList splitCommand(
const QString &command );
77 #if QT_CONFIG(process)
81 QProcess *mProcess =
nullptr;
86 void stdoutAvailable();
87 void stderrAvailable();
88 void processError( QProcess::ProcessError );
89 void processExit(
int, QProcess::ExitStatus );
94 #if QT_CONFIG(process)
109 class CORE_EXPORT QgsBlockingProcess :
public QObject
120 QgsBlockingProcess(
const QString &program,
const QStringList &arguments );
127 void setStdOutHandler(
const std::function<
void(
const QByteArray & ) > &handler ) { mStdoutHandler = handler; }
133 void setStdOutHandler( SIP_PYCALLABLE / AllowNone / );
135 Py_BEGIN_ALLOW_THREADS
137 sipCpp->setStdOutHandler( [a0](
const QByteArray &arg )
140 Py_XDECREF( sipCallMethod( NULL, a0,
"D", &arg, sipType_QByteArray, NULL ) );
153 void setStdErrHandler(
const std::function<
void(
const QByteArray & ) > &handler ) { mStderrHandler = handler; }
159 void setStdErrHandler( SIP_PYCALLABLE / AllowNone / );
161 Py_BEGIN_ALLOW_THREADS
163 sipCpp->setStdErrHandler( [a0](
const QByteArray &arg )
166 Py_XDECREF( sipCallMethod( NULL, a0,
"D", &arg, sipType_QByteArray, NULL ) );
186 QProcess::ExitStatus exitStatus()
const;
193 QProcess::ProcessError processError()
const;
198 QStringList mArguments;
199 std::function< void(
const QByteArray & ) > mStdoutHandler;
200 std::function< void(
const QByteArray & ) > mStderrHandler;
202 QProcess::ExitStatus mExitStatus = QProcess::NormalExit;
203 QProcess::ProcessError mProcessError = QProcess::UnknownError;
211 class ProcessThread :
public QThread
216 ProcessThread(
const std::function<
void()> &
function, QObject *parent =
nullptr )
218 , mFunction( function )
228 std::function<void()> mFunction;
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Interface for showing messages from QGIS in GUI independent way.
A class that executes an external program/script.
static QgsRunProcess * create(const QString &action, bool capture)
#define SIP_NODEFAULTCTORS