* Runs a Python script and returns collected messages as a promise. * If the promise is rejected, the err will probably be of type PythonShellErrorWithLogs * @param scriptPath The path to the script to execute * @param options The execution options
(scriptPath: string, options?: Options)
| 315 | * @param options The execution options |
| 316 | */ |
| 317 | static run(scriptPath: string, options?: Options): Promise<any[]> { |
| 318 | return new Promise((resolve, reject) => { |
| 319 | let pyshell = new PythonShell(scriptPath, options); |
| 320 | let output = []; |
| 321 | |
| 322 | pyshell.on('message', function (message) { |
| 323 | output.push(message); |
| 324 | }).end(function (err) { |
| 325 | if(err){ |
| 326 | (err as PythonShellErrorWithLogs).logs = output |
| 327 | reject(err); |
| 328 | } |
| 329 | else resolve(output); |
| 330 | }); |
| 331 | }); |
| 332 | }; |
| 333 | |
| 334 | |
| 335 |
no test coverage detected