Read the statement by Michael Teeuw here.
Python Shell not working properly on MM
-
Hi again @Jopyth !
I hope im not give you a technical nightmare. Here’s the code that i was running on my MM.const NodeHelper = require('node_helper'); const Gpio = require('onoff').Gpio; const exec = require('child_process').exec; var csv = require('csv-parser'); var fs = require('fs'); var PythonShell = require('python-shell'); var people; module.exports = NodeHelper.create({ start: function () { this.started = false; this.toggleOn = false; //exec("sudo python /home/pi/NicoRFID/RFID_playlist.py"); // RFID, hk forced it here. PythonShell.run('../../../../../home/pi/NicoRFID/RFID_playlist.py', function (err) { if (err) throw err; console.log('finished'); }); function chaofunction(){ fs.createReadStream('/home/pi/MagicMirror/rfid_log.csv') .pipe(csv()) .on('data', function (data) { console.log('People Left: %s ', data.People_left); people = data.People_left; }); } setInterval(chaofunction,4000);
Notice
PythonShell.run('../../../../../home/pi/NicoRFID/RFID_playlist.py', function (err) { if (err) throw err; console.log('finished'); });
-
@zichao92 Looks fine, not sure why it doesn’t work. You do not start he module multiple times, do you?
-
@Jopyth , im not too sure if i accidentally did it , is there any way to check it?
-
@zichao92 It usually should not start multiple helpers. You could insert a
console.log("Script started!");
before thePythonShell.run(...)
and see if it appears multiple times in the log? -
@Jopyth , the console.log didnt even appear once although the RFID is working. Another issue is that the python script will suddenly stop functioning for no reason and it will start functioning again about 1 minute later ( i realized this when the RFID didnt have any response after i tapped a card. )