Code_TYMPAN  4.4.0
Industrial site acoustic simulation
PythonRunner.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
21 #include "PythonRunner.h"
22 #include "Tympan/models/business/subprocess_util.h" // python(...)
23 
24 PythonRunner::PythonRunner(QStringList args, QObject* parent) : QObject(parent), m_args(std::move(args)) {}
25 
27 {
28  std::string err;
29  const bool ok = python(m_args, err);
30  emit finished(ok, QString::fromStdString(err));
31 }
Worker object that runs the blocking python(...) call off the GUI thread.
void finished(bool ok, QString errorMsg)
Emitted when the computation completes.
void run()
Call this slot to start the computation (meant to be invoked from the worker thread).
QStringList m_args
Definition: PythonRunner.h:54
PythonRunner(QStringList args, QObject *parent=nullptr)
bool python(QStringList args, std::string &error_msg)
Launch a Python subprocess and wait for it using a non-blocking UI loop.
Utilities to interact with Python subprocesses from the Tympan application.