-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode_helper.js
29 lines (27 loc) · 971 Bytes
/
node_helper.js
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
29
const spawn = require("child_process").spawn;
var NodeHelper = require("node_helper");
module.exports = NodeHelper.create({
socketNotificationReceived: function(notification, payload) {
switch(notification) {
case "get_torrent":
this.job(payload);
break;
}
},
job: function(args) {
var process = spawn("python3", ["/home/pi/MagicMirror/modules/MMM-Transmission/transmission.py", args.host, args.port, args.username, args.password]);
// TODO: add buffering for data output, check the commented parts
// process.stdout.on('data', chunk => chunks.push(chunk));
// process.stdout.on("end", ()=>{
// try {
// var data = JSON.parse(Buffer.concat(chunks).toString());
// console.log(data);
// } catch (e) {
// console.log(result);
// }
process.stdout.on("data", (data)=>{
console.log(data);
this.sendSocketNotification("tbtTorrent", data.toString())
})
}
})