JS interface to python evaluator for AREPL.
Evaluates python code and sends back the user variables and/or any errors.
Although it is meant for AREPL, it is not dependent upon AREPL and can be used by any project.
Important Note: this should ONLY be used to execute trusted code. It does not have any security features whatsoever.
npm install arepl-backend
must have python 3.7 or greater
see https://github.com/Almenon/AREPL-vscode for example useage.
Semantic release cheatsheet:
| Commit message | Release type |
|----------------------|--------------|
| fix: msg | patch |
| feat: msg | feature |
| perf: msg | |
| BREAKING CHANGE: msg | breaking |
- constructor
- executing
- running
- debounce
- execCode
- sendStdin
- restart
- stop
- start
- onResult
- onPrint
- onStderr
- handleResult
- checkSyntax
- checkSyntaxFile
- formatPythonException
starts python_evaluator.py
options
Process / Python options. If not specified sensible defaults are inferred. (optional, default{}
)
whether python is busy executing inputted code
whether python backend process is running / not running
delays execution of function by ms milliseconds, resetting clock every time it is called Useful for real-time execution so execCode doesn't get called too often thanks to https://stackoverflow.com/a/1909508/6629672
does not do anything if program is currently executing code
code
message
string
kills python process and restarts. Force-kills if necessary after 50ms. After process restarts the callback passed in is invoked
callback
(optional, default()=>{}
)
kills python process. force-kills if necessary after 50ms. you can check python_evaluator.running to see if process is dead yet
starts python_evaluator.py. Will NOT WORK with python 2
Overwrite this with your own handler. is called when program fails or completes
foo
Overwrite this with your own handler. Is called when program prints
foo
string
Overwrite this with your own handler. Is called when program logs stderr
foo
string
handles pyshell results and calls onResult / onPrint
results
string
checks syntax without executing code
code
string
Returns Promise rejects w/ stderr if syntax failure
checks syntax without executing code
filePath
string
Returns Promise rejects w/ stderr if syntax failure
gets rid of unnecessary File "" message in exception
err
err:
Traceback (most recent call last):\n File "<string>", line 1, in <module>\nNameError: name \'x\' is not defined\n