21#ifndef QGSRUNPROCESS_H
22#define QGSRUNPROCESS_H
26#if QT_CONFIG( process )
60 static QgsRunProcess *
create(
const QString &action,
bool capture )
SIP_FACTORY {
return new QgsRunProcess( action, capture ); }
71 static QStringList splitCommand(
const QString &command );
77#if QT_CONFIG( process )
81 std::unique_ptr<QProcess> mProcess;
86 void stdoutAvailable();
87 void stderrAvailable();
88 void processError( QProcess::ProcessError );
89 void processExit(
int, QProcess::ExitStatus );
94#if QT_CONFIG( process )
109class CORE_EXPORT QgsBlockingProcess :
public QObject
119 QgsBlockingProcess(
const QString &program,
const QStringList &arguments );
126 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 ) );
154 void setStdErrHandler(
const std::function<
void(
const QByteArray & ) > &handler ) { mStderrHandler = handler; }
161 void setStdErrHandler( SIP_PYCALLABLE / AllowNone / );
163 Py_BEGIN_ALLOW_THREADS
165 sipCpp->setStdErrHandler( [a0](
const QByteArray &arg )
168 Py_XDECREF( sipCallMethod( NULL, a0,
"D", &arg, sipType_QByteArray, NULL ) );
184 int run( QgsFeedback *feedback =
nullptr );
189 QProcess::ExitStatus exitStatus()
const;
196 QProcess::ProcessError processError()
const;
200 QStringList mArguments;
201 std::function< void(
const QByteArray & ) > mStdoutHandler;
202 std::function< void(
const QByteArray & ) > mStderrHandler;
204 QProcess::ExitStatus mExitStatus = QProcess::NormalExit;
205 QProcess::ProcessError mProcessError = QProcess::UnknownError;
213class ProcessThread :
public QThread
218 ProcessThread(
const std::function<
void()> &function, QObject *parent =
nullptr )
220 , mFunction( function )
223 void run()
override { mFunction(); }
226 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.
Executes an external program/script.
static QgsRunProcess * create(const QString &action, bool capture)
#define SIP_NODEFAULTCTORS