|
Code_TYMPAN
4.4.0
Industrial site acoustic simulation
|
Utilities to interact with Python subprocesses from the Tympan application. More...
#include <QStringList>#include <QTemporaryFile>#include <string>

Go to the source code of this file.
Functions | |
| bool | python (QStringList args, std::string &error_msg) |
| Launch a Python subprocess and wait for it using a non-blocking UI loop. More... | |
| 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=false) |
| Create and initialize a QTemporaryFile according to the current policy. More... | |
| 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... | |
Utilities to interact with Python subprocesses from the Tympan application.
Definition in file subprocess_util.h.
| 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.