-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (24 loc) · 1014 Bytes
/
index.js
File metadata and controls
28 lines (24 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const spawner = require('child_process').spawn;
let python_process = spawner('python', ['./main.py'])
function sendEvent (name, args){
// Define the array and add the default values
spawnerArgs = ['./main.py', `${name}`]
// Check if the event contains arguments
if(typeof args !== 'undefined' ){
// Add every arguments to the array "spawnerArgs"
args.forEach(element => {
spawnerArgs.push(element)
});
}else{
// If it doesn't contain any arguments, do nothing
console.log("Doesn't possess args")
}
// Add the event and its arguments from "spawnerArgs" and the receive part
python_process = spawner('python', spawnerArgs)
python_process.stdout.on('data', (data) => {
console.log('Data received from python :', data.toString())
})
}
// Add events
sendEvent('CreateNewCustomFile', ['Magic Note','This is the event named : ','CreateNewCustomFile'])
sendEvent('LoremIpsumTest', ['Meeska Moska Mickey Mouse','50'])