How to use the python-shell.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 krpeacock / google_home_starter / app.js View on Github external
this.setState = function(state) {
    var str = state === "on" ? onString(this.id[2]) : offString(this.id[2]);
    PythonShell.run(str, function(err) {
      if (!process.env.DEV) {
        if (err) throw err;
      }
    });
    this.state = state;
  };
  // Invokes setState on init to set the switch to its last recalled state.
github WasabiFan / ev3dev-lang-js / test / test-utils.js View on Github external
module.exports.cleanArena = function (callback) {
    PythonShell.run(path.join(fakeSysRootDir, "/clean_arena.py"), function (err) {
        if (err) throw err;

        callback();
    });
}
github midorineko / rpi_automation / app.js View on Github external
});
	}else if(req.params.switch == "off"){
		var options = {
		  args: ['off']
		};
		PythonShell.run('livolo.py', options, function (err) {
			res.statusCode = 302;
			res.setHeader("Location", "/scenes");
			res.end();
		});
	}else{
		var options = {
		  args: [req.params.switch.toLowerCase()]
		};
		inputArgs=req.params.switch.toLowerCase()
		PythonShell.run('scene_main.py', options, function (err) {
			  res.statusCode = 302;
			  var myarr = ['led_off', 'lights_off', 'lights_on', 'all_off', 'led_off', 'led_on'];
			  var route_main = (myarr.indexOf(inputArgs) > -1);
			  if(route_main){
				res.setHeader("Location", "/");
			  }else{
			  	res.setHeader("Location", "/lights/off");
			  }
			  res.end();
			console.log(err)

		});
	}
});
github tonydelanuez / Juxtaposition-Generator / app.js View on Github external
app.get("/data", function(req, res){
	PythonShell.run('scraper.py', function () {
	  //if (err) throw err;
	  console.log('data requested');
	  //console.log(theComment);
	  randomKey();
	});
	res.send(theComment);
});
app.listen(process.env.PORT || 3456);
github SubhasisDutta / Android-APK-Analysis / webapp / server / controllers / appsController.js View on Github external
function runSIG(file_id, apk_input_folder) {
    var SIG_script_location = config.SIG_script_location;
    var SIG_output_location = config.SIG_output_location;
    //console.log(SIG_script_location);
    //console.log(SIG_output_location);
    console.log(apk_input_folder);
    var options = {
        scriptPath: SIG_script_location,
        args: [apk_input_folder, SIG_output_location]
    };
    PythonShell.run('get_field_type.py', options, function (err, results) {
        if (err) return err;
        var output_file = SIG_output_location + "/" + file_id + "_arff_output_complex.arff";
        console.log("File Name: " + output_file);
        fs.readFile(output_file, 'utf8', function (err, contents) {
            //console.log("File ***************************"+contents);
            if (contents === undefined)
                contents = "NO SIG output.";
            updateSIGinDB(file_id, true, contents);
            deleateAllFilesCreated(file_id);
        });
    });
}
github posm / OpenMapKitServer / api / odk / controllers / upload-form.js View on Github external
const xlsToXForm = (xlsPath, callback) => {
  var xformPath = tempy.file({
    extension: 'xml'
  });

  return PythonShell.run('xls2xform.py', {
    pythonPath: 'python2',
    scriptPath: path.join(__dirname, '..', 'pyxform', 'pyxform'),
    args: [xlsPath, xformPath],
    mode: 'text'
  }, (err, results) => {
    if (err) {
      return callback(err);
    }

    return callback(null, xformPath);
  });
};
github petre2dor / piGarden / devices / controller / gpio / md-rd / read.js View on Github external
return new Promise((resolve, reject) => {
        PythonShell.run('controller/gpio/md-rd/read.py', {args: [deviceOptions.GPIOpin]}, (err, results) => {
            let result = err
                            ? { httpCode: 403, type: 'ERROR', message: err.message, data: err }
                            : JSON.parse(results[0])

            if(result.httpCode >= '400') {
                reject({ httpCode: 403, type: 'ERROR', message: 'Read md-rd script failed', data: result.message })
            } else {
                resolve(result)
            }
        })
    })
}
github midorineko / rpi_automation / app.js View on Github external
app.get('/brightness/:value', function (req, res) {
	var options = {
	  args: [req.params.value.toLowerCase()]
	};
    PythonShell.run('brightness.py', options, function (err) {
    	  res.statusCode = 302;
		    if(req.body.brightness == '1-255'){
		  		res.setHeader("Location", "/scenes");
		    }else{
		    	res.setHeader("Location", "/");
		    }
    	  res.end();
    });
});
github midorineko / rpi_automation / app.js View on Github external
res.end();
		});
	}else if(req.params.switch == "lights_off"){
		var options = {
		  args: ['off']
		};
		PythonShell.run('livolo.py', options, function (err) {
			res.statusCode = 302;
			res.setHeader("Location", "/");
			res.end();
		});
	}else if(req.params.switch == "off"){
		var options = {
		  args: ['off']
		};
		PythonShell.run('livolo.py', options, function (err) {
			res.statusCode = 302;
			res.setHeader("Location", "/scenes");
			res.end();
		});
	}else{
		var options = {
		  args: [req.params.switch.toLowerCase()]
		};
		inputArgs=req.params.switch.toLowerCase()
		PythonShell.run('scene_main.py', options, function (err) {
			  res.statusCode = 302;
			  var myarr = ['led_off', 'lights_off', 'lights_on', 'all_off', 'led_off', 'led_on'];
			  var route_main = (myarr.indexOf(inputArgs) > -1);
			  if(route_main){
				res.setHeader("Location", "/");
			  }else{

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