This commit is contained in:
2025-10-21 22:20:26 +02:00
parent 5809e6c44c
commit eb33f47071
10 changed files with 345 additions and 92 deletions

View File

@@ -0,0 +1,27 @@
import { spawn } from 'child_process';
import path from 'path';
export function runPythonScript(scriptPath, args = []) {
return new Promise((resolve, reject) => {
const pythonProcess = spawn('python3', [scriptPath, ...args]);
let stdout = '';
let stderr = '';
pythonProcess.stdout.on('data', (data) => {
stdout += data.toString();
});
pythonProcess.stderr.on('data', (data) => {
stderr += data.toString();
});
pythonProcess.on('close', (code) => {
if (code === 0) {
resolve(stdout);
} else {
reject(new Error(`Python script exited with code ${code}: ${stderr}`));
}
});
});
}