Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

python-shell

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

python-shell - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

3

index.d.ts

@@ -75,2 +75,3 @@ /// <reference types="node" />

static checkSyntax(code: string): Promise<{}>;
static getPythonPath(): string;
/**

@@ -130,3 +131,3 @@ * checks syntax without executing code

receiveStderr(data: string | Buffer): this;
private recieveInternal;
private receiveInternal;
/**

@@ -133,0 +134,0 @@ * Closes the stdin stream, which should cause the process to finish its work and close

@@ -99,21 +99,31 @@ "use strict";

self[name] = self.childProcess[name];
self.parser && self[name].setEncoding(options.encoding || 'utf8');
self.parser && self[name] && self[name].setEncoding(options.encoding || 'utf8');
});
// parse incoming data on stdout
if (this.parser) {
if (this.parser && this.stdout) {
this.stdout.on('data', this.receive.bind(this));
}
// listen to stderr and emit errors for incoming data
this.stderr.on('data', function (data) {
errorData += '' + data;
self.receiveStderr(data);
});
this.stderr.on('end', function () {
if (this.stderr) {
this.stderr.on('data', function (data) {
errorData += '' + data;
self.receiveStderr(data);
});
this.stderr.on('end', function () {
self.stderrHasEnded = true;
terminateIfNeeded();
});
}
else {
self.stderrHasEnded = true;
terminateIfNeeded();
});
this.stdout.on('end', function () {
}
if (this.stdout) {
this.stdout.on('end', function () {
self.stdoutHasEnded = true;
terminateIfNeeded();
});
}
else {
self.stdoutHasEnded = true;
terminateIfNeeded();
});
}
this.childProcess.on('exit', function (code, signal) {

@@ -172,2 +182,5 @@ self.exitCode = code;

}
static getPythonPath() {
return this.defaultOptions.pythonPath ? this.defaultOptions.pythonPath : this.defaultPythonPath;
}
/**

@@ -180,3 +193,4 @@ * checks syntax without executing code

return __awaiter(this, void 0, void 0, function* () {
let compileCommand = `${this.defaultPythonPath} -m py_compile ${filePath}`;
const pythonPath = this.getPythonPath();
const compileCommand = `${pythonPath} -m py_compile ${filePath}`;
return new Promise((resolve, reject) => {

@@ -228,3 +242,3 @@ child_process_1.exec(compileCommand, (error, stdout, stderr) => {

if (!pythonPath)
pythonPath = this.defaultPythonPath;
pythonPath = this.getPythonPath();
const execPromise = util_1.promisify(child_process_1.exec);

@@ -235,3 +249,3 @@ return execPromise(pythonPath + " --version");

if (!pythonPath)
pythonPath = this.defaultPythonPath;
pythonPath = this.getPythonPath();
return child_process_1.execSync(pythonPath + " --version").toString();

@@ -271,2 +285,4 @@ }

send(message) {
if (!this.stdin)
throw new Error("stdin not open for writting");
let data = this.formatter ? this.formatter(message) : message;

@@ -286,3 +302,3 @@ if (this.mode !== 'binary')

receive(data) {
return this.recieveInternal(data, 'message');
return this.receiveInternal(data, 'message');
}

@@ -297,6 +313,6 @@ ;

receiveStderr(data) {
return this.recieveInternal(data, 'stderr');
return this.receiveInternal(data, 'stderr');
}
;
recieveInternal(data, emitType) {
receiveInternal(data, emitType) {
let self = this;

@@ -327,3 +343,5 @@ let parts = ('' + data).split(new RegExp(os_1.EOL, 'g'));

end(callback) {
this.childProcess.stdin.end();
if (this.childProcess.stdin) {
this.childProcess.stdin.end();
}
this._endCallback = callback;

@@ -345,3 +363,2 @@ return this;

// starting 2020 python2 is deprecated so we choose 3 as default
// except for windows which just has "python" command
PythonShell.defaultPythonPath = process.platform != "win32" ? "python3" : "py";

@@ -348,0 +365,0 @@ PythonShell.defaultOptions = {}; //allow global overrides for options

{
"name": "python-shell",
"version": "1.0.7",
"version": "1.0.8",
"description": "Run Python scripts from Node.js with simple (but efficient) inter-process communication through stdio",

@@ -10,3 +10,3 @@ "keywords": [

"test": "tsc -p ./ && mocha",
"appveyorTest": "tsc -p ./ && mocha --reporter mocha-appveyor-reporter test/*.js",
"appveyorTest": "tsc -p ./ && nyc mocha --reporter mocha-appveyor-reporter test/*.js",
"compile": "tsc -watch -p ./"

@@ -13,0 +13,0 @@ },

@@ -1,3 +0,4 @@

# [python-shell](https://www.npmjs.com/package/python-shell) [![Build status](https://ci.appveyor.com/api/projects/status/m8e3h53vvxg5wb2q?svg=true)](https://ci.appveyor.com/project/Almenon/python-shell)
# [python-shell](https://www.npmjs.com/package/python-shell) [![Build status](https://ci.appveyor.com/api/projects/status/m8e3h53vvxg5wb2q?svg=true)](https://ci.appveyor.com/project/Almenon/python-shell) [![codecov](https://codecov.io/gh/extrabacon/python-shell/branch/master/graph/badge.svg)](https://codecov.io/gh/extrabacon/python-shell)
<!-- chage above url accroding to repo -->
A simple way to run Python scripts from Node.js with basic but efficient inter-process communication and better error handling.

@@ -4,0 +5,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc