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

Method runString

index.ts:342–350  ·  view source on GitHub ↗

* Runs the inputted string of python code and returns collected messages as a promise. DO NOT ALLOW UNTRUSTED USER INPUT HERE! * @param code The python code to execute * @param options The execution options * @return a promise with the output from the python script

(code: string, options?: Options)

Source from the content-addressed store, hash-verified

340 * @return a promise with the output from the python script
341 */
342 static runString(code: string, options?: Options) {
343
344 // put code in temp file
345 const randomInt = getRandomInt();
346 const filePath = tmpdir + sep + `pythonShellFile${randomInt}.py`
347 writeFileSync(filePath, code);
348
349 return PythonShell.run(filePath, options);
350 };
351
352 static getVersion(pythonPath?: string) {
353 if (!pythonPath) pythonPath = this.getPythonPath()

Callers 1

Calls 2

getRandomIntFunction · 0.85
runMethod · 0.80

Tested by

no test coverage detected