MCPcopy Index your code
hub / github.com/extrabacon/python-shell / run

Method run

index.ts:317–332  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 4

runStringMethod · 0.80
runSingleErrorScriptFunction · 0.80
runSingleScriptFunction · 0.80

Calls 2

onMethod · 0.95
endMethod · 0.80

Tested by

no test coverage detected