Socket
Socket
Sign inDemoInstall

arepl-backend

Package Overview
Dependencies
1
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    arepl-backend

JS interface to python evaluator for AREPL


Version published
Weekly downloads
22
increased by22.22%
Maintainers
1
Install size
300 kB
Created
Weekly downloads
 

Readme

Source

AREPL-backend npm version example workflow

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.

Installation

npm install arepl-backend

must have python 3.7 or greater

Usage

see https://github.com/Almenon/AREPL-vscode for example useage.

For developers:

Semantic release cheatsheet:

| Commit message       | Release type |
|----------------------|--------------|
| fix: msg             | patch        |
| feat: msg            | feature      |
| perf: msg            |              |
| BREAKING CHANGE: msg | breaking     |

API

Table of Contents

constructor

starts python_evaluator.py

Parameters
  • options Process / Python options. If not specified sensible defaults are inferred. (optional, default {})

executing

whether python is busy executing inputted code

running

whether python backend process is running / not running

debounce

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

execCode

does not do anything if program is currently executing code

Parameters
  • code

sendStdin

Parameters

restart

kills python process and restarts. Force-kills if necessary after 50ms. After process restarts the callback passed in is invoked

Parameters
  • callback (optional, default ()=>{})

stop

kills python process. force-kills if necessary after 50ms. you can check python_evaluator.running to see if process is dead yet

start

starts python_evaluator.py. Will NOT WORK with python 2

onResult

Overwrite this with your own handler. is called when program fails or completes

Parameters
  • foo

onPrint

Overwrite this with your own handler. Is called when program prints

Parameters

onStderr

Overwrite this with your own handler. Is called when program logs stderr

Parameters

handleResult

handles pyshell results and calls onResult / onPrint

Parameters

checkSyntax

checks syntax without executing code

Parameters

Returns Promise rejects w/ stderr if syntax failure

checkSyntaxFile

checks syntax without executing code

Parameters

Returns Promise rejects w/ stderr if syntax failure

formatPythonException

gets rid of unnecessary File "" message in exception

Parameters
  • err
Examples
err:
Traceback (most recent call last):\n  File "<string>", line 1, in <module>\nNameError: name \'x\' is not defined\n

Keywords

FAQs

Last updated on 06 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc