Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.post('/infoContent', function(req, res) {
// invoke this just once, and send all the data over to the client.
// This will make the code more responsive.
// var infoContentParams = req.body;
var pyShell = new PythonShell('infoContent.py', options)
// pyShell.send(req.body.data);
// send the transcript text to the python shell
pyShell.send(outputtrans.target);
pyShell.on('message', function(message) {
infoContentDict = message
console.log(infoContentDict)
res.status(200).send({data: infoContentDict});
// res.send(200, {data: infoContentDict});
// outputInfoContent.target = infoContentParams.infoContent;
});
pyShell.end(function(err) {
if (err) throw err;
});
});
'--method=' + this.config.method,
'--detectionMethod=' + this.config.detectionMethod,
'--interval=' + this.config.checkInterval,
'--output=' + this.config.output,
'--extendDataset=' + extendedDataset,
'--dataset=' + this.config.dataset,
'--tolerance=' + this.config.tolerance
],
};
if (this.config.pythonPath != null && this.config.pythonPath !== '') {
options.pythonPath = this.config.pythonPath;
}
// Start face reco script
self.pyshell = new PythonShell(
'modules/' + this.name + '/tools/facerecognition.py',
options
);
// check if a message of the python script is comming in
self.pyshell.on('message', function(message) {
// A status message has received and will log
if (message.hasOwnProperty('status')) {
console.log('[' + self.name + '] ' + message.status);
}
// Somebody new are in front of the camera, send it back to the Magic Mirror Module
if (message.hasOwnProperty('login')) {
console.log(
'[' +
self.name +
'--baud', params.baudRate,
'--before', params.before,
'--after', params.after,
'write_flash', params.compress,
'--flash_mode', params.flashMode,
'--flash_freq', params.flashFreq,
'--flash_size', params.flashSize,
params.initialOTAIndex, params.initialOTADataBin,
params.bootloaderIndex, params.bootloaderBin,
params.partitionsTableIndex, params.partitionsBin,
params.factorySerialIndex, params.factorySerialBin,
params.appIndex, params.appBin
]
}
const pyShell = new PythonShell('esptool.py', options)
pyShell.on('message', (message) => {
const messageArray = message.split('\r')
messageArray.forEach((messageItem) => {
const msg = { id: uuidv4(), data: messageItem }
mainWindow.webContents.send('flashing-progress-updated', msg)
})
})
pyShell.end((err, code, signal) => {
if (err) {
mainWindow.webContents.send('flashing-progress-completed', 1, null)
throw err
}
mainWindow.webContents.send('flashing-progress-completed', code, signal)
})
constructor() {
var pythonPath = settings.read('midi').filter(x=>x.includes('path=')).map(x=>x.split('=')[1])[0]
this.py = new PythonShell('python/midi.py', Object.assign({
args: [
settings.read('debug') ? 'debug' : '',
...settings.read('midi')
],
pythonPath
}, pythonOptions))
}
job: function(config) {
this.config = config
var map = this.config.gestureMapFromTo
var py = path.resolve(__dirname, "py", "gesture_print.py")
var option = {
mode: "text",
pythonPath:this.config.pythonPath,
pythonOptions: ['-u'],
}
this.shell = new PythonShell(py, option)
this.shell.on("message", (message)=>{
this.log("[GESTURE] ORIGIN:" + message)
var gesture = null
gesture = (map.hasOwnProperty(message)) ? map[message] : null
if (gesture) {
this.gestureProcess(gesture)
}
})
this.shell.on("error", (message)=>{
this.shell.end()
if (!message.traceback.search("KeyboardInterrupt")) {
this.log(message)
} else {
this.log("Keyboard Interrupted")
}
this.log("[GESTURE] Gesture script is finished.")