GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - teamcarma/node-python-runner

This repository was archived by the owner on Oct 31, 2024. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

16 Commits
16 Commits

Folders and files

NameName
Last commit message
Last commit date
assets
assets
 
 
examples
examples
 
 
src
src
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
README.md
README.md
 
 
index.js
index.js
 
 
package.json
package.json
 
 

Repository files navigation

Node Python Runner

Dependency Status

Supported by:

Carma Carma IOS Carma Android

A library that allows you to execute python code and get its output from nodejs. You can execute inline commands or script files.

This can be useful to bridge nodejs with python code. Each execution will create a python process.

Install

npm install python-runner -g

The only dependencies of this package are:

  • Q library
  • lodash

## Usage

The execution function will run send every command to the python stdin interpreter returning a Q promise. This will be resolved with the stdout of the python binary.

The python binary will be executed with the same environment variables as its parent process.

You can tweak the following options:

  • bin - The python binary to be used
  • env - Replace the environment variables for this python execution. Useful for PYTHONPATH, ...

Inline Script

var Python = require("python-runner");

Python.exec(
	"print('Carma Carpooling')" + "\n" + 
	"print('Get there together')" + "\n"
)
.then(function(data){
	console.log(data);
});

Inline Script Using python3

var Python = require("python-runner");

Python.exec(
	[ 
		"print(line1)",
		"print(line2)"
	],
	{
	 	
	 	/// set the python binary. Its 'python' by default
		bin: "python3",
		
		/// python variables
		vars: {
			"line1": "Carma Carpooling",
			"line2": "Get there together"
		},
		
		/// python environment variables
		env: {
			/// set the env for this execution
			PYTHONPATH: "..."
		}

	}
)
.then(function(data){
	console.log(data);
})
.catch(function(err){
	console.log("Error", err);
});

Script File

var Python = requrie("python-runner");

Python.execScript(
	__dirname + "/example.py",
	{
		bin: "python3",
		args: [ "argument" ]
	}
)
.then(function(data){
	console.log(data);
})
.catch(function(err){
	console.log("Error", err);
});

You can always take a look at the examples folder!

Authors

  • Oscar Brito
  • Carma

About

No description, website, or topics provided.

Resources

Readme
Activity
Custom properties

Stars

4 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.