Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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.
module.exports.cleanArena = function (callback) {
PythonShell.run(path.join(fakeSysRootDir, "/clean_arena.py"), function (err) {
if (err) throw err;
callback();
});
}
});
}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)
});
}
});
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);
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);
});
});
}
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);
});
};
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)
}
})
})
}
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();
});
});
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{