Run python scripts and pass data between multiple python and node processes using this npm module

Overview

A Simpler way to run Python code inside Node.

Run python scripts and pass data between multiple python and node processes using this npm module. process-communication has a event based architecture for interacting with python data and errors inside nodejs.

Currently I have plans to create a pip module for easier communication inside python so you dont have to directly work with the stdout.flush functions.

console.log(data.toString())); // convert buffer to a string //listen and handle errors process.listen.on("error", (err) => console.log(err)) // listen for the script to finish process.listen.on("close", () => console.log('closed event fired')) ">
let PythonController = require("node-python-communication").Process;

let process = new PythonController();

process.configure(`${__dirname}\\main.py`, [true, "Hello World", 10.5]); // random test data can be all data types.

// run the script
process.start();

// listen for more data
process.listen.on("data", (data) => console.log(data.toString())); // convert buffer to a string

//listen and handle errors
process.listen.on("error", (err) => console.log(err))

// listen for the script to finish
process.listen.on("close", () => console.log('closed event fired'))

In your python script the only requirements are you import the sys module for getting the args passed from js.

import sys, time

# to access arg1 then simply select
arg_one = sys.argv[1] # true

# arg 2
arg_two = sys.argv[2] # "Hello World"

arg_three = sys.argv[3] # 10.5 It may need to be converted to a float before it can be used in python 

print(f"hello from the python process this is some random data: {10 * float(arg_three)}")
sys.stdout.flush() # flush the file when you are ready to send back data
# flushing will fire the on("data") event in the javascript file


# Wait 10 seconds for close event to fire after script ends
time.sleep(10)
print("waited 10 seconds now I will fire the closed event")
sys.stdout.flush()

AndroidEnv is a Python library that exposes an Android device as a Reinforcement Learning (RL) environment.

AndroidEnv is a Python library that exposes an Android device as a Reinforcement Learning (RL) environment.

DeepMind 814 Dec 26, 2022
A water drinking notification every hour to keep you healthy while coding :)

Water_Notification A water drinking notification every hour to keep you healthy while coding. 馃挧 馃挧 Stay Hydrated Stay Healthy 馃挧 馃挧 Authors @CrazyCat

Arghya Banerjee 1 Dec 22, 2021
VacationCycleLogicBackEnd - Vacation Cycle Logic BackEnd With Python

Vacation Cycle Logic BackEnd Getting Started Existing virtualenv If your project

Mohamed Gamal 0 Jan 03, 2022
AutoMetamon: Simple program to play Metamon automatically

AutoMetamon: Simple program to play Metamon automatically

Ng么 V膬n Tu岷 2 Sep 13, 2022
A python script that will automate the boring task of login to the captive portal again and again

A python script that will automate the boring task of login to the captive portal again and again

Rakib Hasan 2 Feb 09, 2022
Grail(TM) is a web browser written in Python

Grail is distributed in source form. It requires that you have a Python interpreter and a Tcl/Tk installation, with the Python interpreter configured for Tcl/Tk support.

22 Oct 18, 2022
Python library for converting Python calculations into rendered latex.

Covert art by Joshua Hoiberg handcalcs: Python calculations in Jupyter, as though you wrote them by hand. handcalcs is a library to render Python calc

Connor Ferster 5.1k Jan 07, 2023
Sacred is a tool to help you configure, organize, log and reproduce experiments developed at IDSIA.

Sacred Every experiment is sacred Every experiment is great If an experiment is wasted God gets quite irate Sacred is a tool to help you configure, or

IDSIA 4k Jan 02, 2023
Time python - C贸digos para auxiliar e mostrar formas de como fazer um rel贸gio e manipular o seu tempo

Time_python C贸digos para auxiliar e mostrar formas de como fazer um rel贸gio e manipular o seu tempo. Bibliotecas Nestes foram usadas bibliotecas nativ

Eduardo Henrique 1 Jan 03, 2022
Create an application to visualize single/multiple Xandar Kardian people counting sensors detection result for a indoor area.

Program Design Purpose: We want to create an application to visualize single/multiple Xandar Kardian people counting sensors detection result for a indoor area.

2 Dec 28, 2022
SECRET SANTA / KRIS KINGLE

SECRET SANTA / KRIS KINGLE Note: Before executing the script, make sure to turn

DEV_FINWIZ 10 Dec 06, 2022
Generate Gaussian 09 input files for the rotamers of an input compound.

Rotapy Purpose Generate Gaussian 09 input files for the rotamers of an input compound. Distance to the axis of rotation remains constant throughout th

1 Jul 16, 2021
Repo created for the purpose of adding any kind of programs and projects

Programs and Project Repository A repository for adding programs and projects of any kind starting from beginners level to expert ones Contributing to

Unicorn Dev Community 3 Nov 02, 2022
Simple script with AminoLab to send ghost messages

Simple script with AminoLab to send ghost messages

Moleey 1 Nov 22, 2021
A simply program to find active jackbox.tv game codes

PeepingJack A simply program to find active jackbox.tv game codes How does this work? It uses a threadpool to loop through all possible codes in a ran

3 Mar 20, 2022
Xbps-install wrapper written in Python that doesn't care about case sensitiveness and package versions

xbi Xbps-install wrapper written in Python that doesn't care about case sensitiveness and package versions. Description This Python script can be easi

Emanuele Sabato 5 Apr 11, 2022
An Insurance firm providing tour insurance is facing higher claim frequency

An Insurance firm providing tour insurance is facing higher claim frequency. Data is collected from the past few years. Made a model which predicts the claim status using CART, RF & ANN and compare t

1 Jan 27, 2022
WGGCommute - Adding Commute Times to WG-Gesucht Listings

WGGCommute - Adding Commute Times to WG-Gesucht Listings This is a barebones implementation of a chrome extension that can be used to add commute time

Jannis 2 Jul 20, 2022
馃寛Python cheatsheet for all standard libraries(Continuously Updated)

Python Standard Libraries Cheatsheet Depend on Python v3.9.8 All code snippets have been tested to ensure they work properly. Fork me on GitHub. 涓枃 En

nick 12 Dec 27, 2022
馃挕 Fully automatic light management based on conditions like motion, illuminance, humidity, and other clever features

Fully automatic light management based on motion as AppDaemon app. 馃晸 multiple daytimes to define different scenes for morning, noon, ... 馃挕 supports

Ben 105 Dec 23, 2022