|
Code_TYMPAN
4.4.0
Industrial site acoustic simulation
|
Utilitaires pour les interactions entre l'application tympan et des sous-processus python. More...
#include <QFile>#include <QCoreApplication>#include <QProcess>#include <QDir>#include <QRegularExpression>#include <QEventLoop>#include <QTimer>#include <QElapsedTimer>#include <atomic>#include "Tympan/core/defines.h"#include "Tympan/core/chrono.h"#include "Tympan/core/logging.h"#include "Tympan/core/exceptions.h"#include "subprocess_util.h"
Go to the source code of this file.
Macros | |
| #define | TYMPAN_REL_CYTHON_PATH "cython" |
| #define | COMPUTATION_TIMEOUT 10000 |
Functions | |
| void | python_request_cancel () |
| Request cancellation of the currently running Python subprocess (UI hook, stage A). More... | |
| bool | python_cancel_was_requested () |
| Query whether a cancellation was requested since the last call to python(). More... | |
| QStringList | _python_qprocess_environment () |
| QString | _get_python_interp () |
| std::string | _read_environment_variables (QStringList env) |
| bool | must_keep_tmp_files () |
| Tell whether temporary files should be preserved (debug mode). More... | |
| bool | init_tmp_file (QTemporaryFile &tmp_file, bool keep_file) |
| Create and initialize a QTemporaryFile according to the current policy. More... | |
| bool | python (QStringList args, std::string &error_msg) |
| Launch a Python subprocess and wait for it using a non-blocking UI loop. More... | |
Utilitaires pour les interactions entre l'application tympan et des sous-processus python.
Definition in file subprocess_util.cpp.
| #define COMPUTATION_TIMEOUT 10000 |
Definition at line 44 of file subprocess_util.cpp.
| #define TYMPAN_REL_CYTHON_PATH "cython" |
Definition at line 41 of file subprocess_util.cpp.
| QString _get_python_interp | ( | ) |
Definition at line 128 of file subprocess_util.cpp.
| QStringList _python_qprocess_environment | ( | ) |
Definition at line 76 of file subprocess_util.cpp.
| std::string _read_environment_variables | ( | QStringList | env | ) |
Definition at line 149 of file subprocess_util.cpp.
| bool init_tmp_file | ( | QTemporaryFile & | tmp_file, |
| bool | keep_file = false |
||
| ) |
Create and initialize a QTemporaryFile according to the current policy.
The function ensures the file exists and is ready to be written to. Depending on keep_file and the global policy, the file may be configured to persist after the object is destroyed.
| tmp_file | Reference to a QTemporaryFile object to initialize (not yet opened). |
| keep_file | If true, prevents auto-removal on destruction (useful for debugging). |
Definition at line 200 of file subprocess_util.cpp.

| bool must_keep_tmp_files | ( | ) |
Tell whether temporary files should be preserved (debug mode).
The policy (environment variables, build flags, etc.) is defined in the implementation. When this returns true, callers may avoid auto-removal of temporary artifacts for diagnostics.
Definition at line 185 of file subprocess_util.cpp.

| bool python | ( | QStringList | args, |
| std::string & | error_msg | ||
| ) |
Launch a Python subprocess and wait for it using a non-blocking UI loop.
This function starts a Python interpreter with the given arguments and runs a local Qt event loop until the subprocess finishes (successfully or not). It is synchronous from the caller's perspective (returns when the process ends), but it does not block the GUI thread: the Qt event loop remains responsive.
Cancellation can be requested from the UI by calling python_request_cancel().
| args | Argument list passed to the Python interpreter (first item is the script path). | |
| [out] | error_msg | On failure, filled with a human-readable message in French intended for end users. |
Definition at line 213 of file subprocess_util.cpp.

| bool python_cancel_was_requested | ( | ) |
Query whether a cancellation was requested since the last call to python().
Useful on the UI side to adapt user messaging (e.g., distinguishing a user-initiated interruption from an execution error).
Definition at line 54 of file subprocess_util.cpp.
| void python_request_cancel | ( | ) |
Request cancellation of the currently running Python subprocess (UI hook, stage A).
Thread-safe with respect to the UI thread. The implementation attempts a graceful QProcess::terminate(), then issues QProcess::kill() after a short grace period if needed. Calling this when no subprocess is running is a no-op.
Definition at line 49 of file subprocess_util.cpp.