How to use the python-shell.PythonShell.run function in python-shell

To help you get started, we’ve selected a few python-shell examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github justinmoon / junction / index.js View on Github external
function createWindow () {
  // run junction
  PythonShell.run('electron.py', {}, function  (err, results)  {
   if  (err)  console.log(err);
  });

  // open browser windows, visit junction
  window = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nativeWindowOpen: true,
    },
  })

  window.webContents.on('new-window', (event, url, frameName, disposition, options, additionalFeatures) => {
    if (frameName === 'modal') {
      // open window as modal
      event.preventDefault()
github geojacobm6 / keyword_finder / js / main.js View on Github external
(async () => {
        let port = await getPort()
        let script = getScriptPath()
        global.port = port;
        var options = {
          args: [port]
        };
        console.log(script)
        console.log(script)
        if (guessPackaged()) {
            global.py_proc = require('child_process').execFile(script, [port])
        } else {
            global.py_proc = PythonShell.run(script, options,  function  (err, results)  {
             if  (err)  console.log(err);
            });
        }
//        PythonShell.run('./backend/engine.py', options,  function  (err, results)  {
//         if  (err)  console.log(err);
//        });

        window = new BrowserWindow({width: 800, height: 600,
                                    frame: true,
                                    webPreferences: {
                                        webSecurity: false,
                                        plugins: true
                                        },
                                    });
//        window.webContents.openDevTools()
github lovell / cc / bin / cpplint.js View on Github external
args.push("--filter");
      args.push(
        config.filter
          .map(function(filter) {
            return `-${filter}`;
          })
          .join(",")
      );
    }
    const cppLintOptions = {
      pythonPath,
      scriptPath: __dirname,
      args: args.concat(files)
    };

    PythonShell.run("cpplint.py", cppLintOptions, function(err) {
      if (err) {
        console.error(err.message);
        process.exit(1);
      }
    });
  } else {
    console.error(`No files found matching ${config.files.join(", ")}`);
    process.exit(1);
  }
});
github jean-emmanuel / open-stage-control / src / server / midi.js View on Github external
static list() {

        var pythonPath = settings.read('midi') ? settings.read('midi').filter(x=>x.includes('path=')).map(x=>x.split('=')[1])[0] : undefined

        PythonShell.run('python/list.py', Object.assign({pythonPath}, pythonOptions), function(err, results) {
            if (err) console.error(err)
            MidiConverter.parseIpc(results)
        })

    }
github OpenCTI-Platform / opencti / opencti-platform / opencti-graphql / src / database / utils.js View on Github external
return new Promise((resolve, reject) => {
      const options = {
        mode: 'text',
        pythonPath: 'python3',
        scriptPath,
        args
      };
      return PythonShell.run(scriptName, options, (err, results) => {
        if (err) {
          reject(new Error(`Python3 is missing or script not found: ${err}`));
        }
        try {
          const result = JSON.parse(results[0]);
          resolve(result);
        } catch (err2) {
          reject(new Error(`No valid JSON from Python script: ${err2}`));
        }
      });
    });
  } catch (err) {
github dawg / vusic / src / dawg / extensions / core / models.ts View on Github external
message: 'Models Path Not Found',
      details: 'Please enter a valid models repository path in the projects settings.',
    });

    return;
  }

  if (opts.samplePath !== null) {
    const options: Options = {
        mode: 'text',
        pythonPath: opts.pythonPath,
        scriptPath: opts.modelsPath,
        args: [opts.samplePath],
    };

    PythonShell.run(opts.scriptPath, options, (err?: Error) => {
      if (err) {
        return opts.cb({
          type: 'error',
          message: 'Unknown Error',
          details: err.message,
        });
      }

      opts.cb({
        type: 'success',
        message: 'Model Ran Successfully',
        details: 'Check the File Explorer for the model output.',
      });
    });
  } else {
    opts.cb({
github Scony / godot-gdscript-toolkit / editor-plugins / vscode / src / extension.ts View on Github external
let options = PythonShell.defaultOptions;
    options.scriptPath = SCRIPT_PATH;

    const pythonPath: string | undefined = vscode.workspace
        .getConfiguration("python")
        .get("pythonPath");
    if (!!pythonPath) {
        options.pythonPath = pythonPath;
    }

    let input = script;

    options.args = PY_ARGS;
    options.args[0] = input;

    PythonShell.run(SCRIPT_NAME, options, (err, results) => {
        if (err) {
            onPythonError(err, uri);
        } else {
            callback(results);
        }
    });
}

python-shell

Run Python scripts from Node.js with simple (but efficient) inter-process communication through stdio

MIT
Latest version published 1 year ago

Package Health Score

72 / 100
Full package analysis