mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-12-02 16:13:48 +08:00
b9c815d56a
* Universal PyProcess module runner. Migration cli * print to stderr * Migration in jotpluggler * Do - * Improvements * Explicit stdout * Existing master pyprocess changes * PyTools * Fix runtime warning
22 lines
864 B
C++
22 lines
864 B
C++
#pragma once
|
|
|
|
#include <atomic>
|
|
#include <functional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace PyProcess {
|
|
|
|
// Called with each line of the child's stderr (newline-terminated).
|
|
using StderrLineCallback = std::function<void(const char *line)>;
|
|
|
|
// Run a Python module (`python3 -m <module> <args...>`) and capture stdout.
|
|
// Stderr lines are passed to stderr_line_cb if set, otherwise through to the parent's stderr.
|
|
// If trim is true (default), trailing newlines are removed from the returned stdout content.
|
|
// Returns empty string on failure. If abort is signaled, kills the child process.
|
|
std::string runModule(const std::string &module, const std::vector<std::string> &args,
|
|
std::atomic<bool> *abort = nullptr, bool trim = true,
|
|
const StderrLineCallback &stderr_line_cb = nullptr);
|
|
|
|
} // namespace PyProcess
|