Closed basti0001 closed 7 years ago
I am not sure what causes this, I will have a look at this when I am back from vacation. IP address and port are currently not being transferred to the python program. I was working on this on my development branch. If you want you can try the code there.
It seems as if your /bin/sh
which is used for exec
does not exist. Can you look at the output of this ls -la /bin/sh
? If it looks fine, this /bin/sh -c 'echo "HELLO" > test'
should create a file called test
in your working directory with the content HELLO WORLD
Hi paviro, how was the holyday ;-) hope your're fine and relaxed ;-)))
ls -la /bin/sh says:
lrwxrwxrwx 1 root root 4 Jan 21 2014 /bin/sh -> dash
so looks fine I guess.
/bin/sh -c 'echo "HELLO" > test'
creates the file 'test' but it contains only 'HELLO' ;-)) not 'HELLO WORLD'. It seems something is missing in the environment path since I installed node.js manually; maybe.
Not shure. I commended out the complete fritz_access.py and just tried to run a python command liek "python -v" with the same result.
Cheers
Sebastian
It seems as if your |/bin/sh| which is used for |exec| does not exist. Can you look at the output of this |ls -la /bin/sh|? If it looks fine, this |/bin/sh -c 'echo "HELLO" > test'| should create a file called |test| in your working directory with the content |HELLO WORLD|
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/issues/20#issuecomment-252621376, or mute the thread https://github.com/notifications/unsubscribe-auth/AVky4CsZC1yxNmnkqAi7A8G9O9ytDXtXks5qykCegaJpZM4KO-GZ.
Sebastian Merkel Kellerbergstraße 30 84030 Landshut
+49 (0) 871 95352675 +49 (0) 160 94646736
sebastian.merkel@gmail.com sebastian.merkel@zoho.com
Hi Sebastian,
I am not Paviro, that is the original author of this module, I just added the FRITZ!Box connection. But my holiday was fine, and I am refreshed to hopefully help you solve this problem. ;)
So python --version
also created the ENOENT error?
The main problem is, I can not reproduce this issue. How do you start your mirror? Is your working directory different from the default one (which would be in the MagicMirror
directory)? Can you add a line above this one and paste this:
exec('echo "this is the working directory" > findme1.txt', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});
If this works, try to find the file that we just created (find . -type f -name findme1.txt -prune
).
exec('python -c "f = file(\'findme2.txt\',\'w\'); f.write(\'this is the working directory\'); f.close()"', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});
If that works do the same with the python command and try to find the findme2.txt
.
Last but not least, you can try to change the working directory in this line.
Hi Jopyth, thx 4 your answer. Maybe i find some time this evening to check your suggestions. Short 4 now: yes i replaced the complete command with 'python -v' that just should print the Installed Version just like in a shell. That also raised the exception.
I installed the Base package in /var/www/html/magicmirror
Your package is cloned via git into the module folder. I guess this is all according to help / default But i am running the mm2 in the Server Mode since i only have a raspberry Pi B+. Also Jessie is shipped with node.js Way to Old. I installed the latest 6.7.0 package manually. May be a Missing path/Export. I think i already changed the complete paths in the node_helper.js to the folder/Files (fritz_access.py). Result was the very same execption. But maybe i have time to check again this afternoon.
Cheers & thx so far
Sebastian
Ps: am writing a c++ Applications for object detection 4 the mirror Switch onoff HDMI and in the night we completly Cut Off supplvoltage for Monitor with Relais to save Power.
Am 10.10.2016 9:52 nachm. schrieb "Jopyth" notifications@github.com:
Hi Sebastian,
I am not Paviro, that is the original author of this module, I just added the FRITZ!Box connection. But my holiday was fine, and I am refreshed to hopefully help you solve this problem. ;)
So python --version also created the ENOENT error?
The main problem is, I can not reproduce this issue. How do you start your mirror? Is your working directory different from the default one (which would be in the MagicMirror directory)? Can you add a line above this one https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/blob/master/node_helper.js#L190 and paste this: exec('echo "this is the working directory" > findme1.txt', (error, stdout, stderr) => { if (error) { console.error(
exec error: ${error}
); return; } console.log(stdout: ${stdout}
); console.log(stderr: ${stderr}
); }); If this works, try to find the file that we just created (find . -type f -name findme1.txt -prune). exec('python -c "f = file('findme2.txt','w'); f.write('this is the working directory'); f.close()"', (error, stdout, stderr) => { if (error) { console.error(exec error: ${error}
); return; } console.log(stdout: ${stdout}
); console.log(stderr: ${stderr}
); }); If that works do the same with the python command and try to find the findme2.txt.Last but not least, you can try to change the working directory in this line https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/blob/master/node_helper.js#L175.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/issues/20#issuecomment-252729134, or mute the thread https://github.com/notifications/unsubscribe-auth/AVky4KAB_k-WVcgsT9Q3odtX2HbdHWMZks5qypeIgaJpZM4KO-GZ .
Hi Jopyth, ok I did as recommended. I added the creation of the file as you suggested before the call of the fritz_access.py command.
the log of mm2 did not receive an error.
I searched for the file with:
sudo find // -name 'findme1.txt' //var/www/html/MagicMirror/modules/MMM-FRITZ-Box-Callmonitor/findme1.txt
So the path should be correct I presume.
cat findme1.txt this is the working directory
Ok thats what we wrote into the file during the node_helper.js. So far so good.
Now I tried the code you posted:
exec('python -c "f = file('findme2.txt','w'); f.write('this is the
working directory'); f.close()"', (error, stdout, stderr) => {
if (error) {
console.error(exec error: ${error}
);
return;
}
console.log(stdout: ${stdout}
);
console.log(stderr: ${stderr}
);
});
Here it seems is a little bug in the command. Starting MM2 with
sudo node /var/www/html/MagicMirror/serveronly/index.js
resulted in an error:
Whoops! There was an uncaught exception... /var/www/html/MagicMirror/modules/MMM-FRITZ-Box-Callmonitor/node_helper.js:209 exec('python -c "f = file('findme2.txt','w'); f.write('this is the working directory'); f.close()"', (error, stdout, stderr) => {
SyntaxError: missing ) after argument list at Object.exports.runInThisContext (vm.js:76:16) at Module._compile (module.js:528:28) at Object.Module._extensions..js (module.js:565:10) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) at Function.Module._load (module.js:424:3) at Module.require (module.js:483:17) at require (internal/module.js:20:19) at loadModule (/var/www/html/MagicMirror/js/app.js:83:17) at loadModules (/var/www/html/MagicMirror/js/app.js:100:4)
simply running the python command in the shell works
sudo python -c "f = file('findme2.txt','w'); f.write('this is the working directory'); f.close()"
creates the file with the content. So I guess there must be some error in the syntax in the js here:
exec('python -c "do something"', (error, stdout, stderr) =>
{
if (error) {
console.error(exec error: ${error}
);
return;
}
console.log(stdout: ${stdout}
);
console.log(stderr: ${stderr}
);
});
I checked tha brackets and see no mistake. Sry my .js knowledge is pretty bad ;-)
Cheers
Sebastian
Hi Sebastian,
I am not Paviro, that is the original author of this module, I just added the FRITZ!Box connection. But my holiday was fine, and I am refreshed to hopefully help you solve this problem. ;)
So |python --version| also created the /ENOENT/ error?
The main problem is, I can not reproduce this issue. How do you start your mirror? Is your working directory different from the default one (which would be in the |MagicMirror| directory)? Can you add a line above this one https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/blob/master/node_helper.js#L190 and paste this: |exec('echo "this is the working directory" > findme1.txt', (error, stdout, stderr) => { if (error) { console.error(
exec error: ${error}
); return; } console.log(stdout: ${stdout}
); console.log(stderr: ${stderr}
); });| If this works, try to find the file that we just created (|find . -type f -name findme1.txt -prune|). |exec('python -c "f = file('findme2.txt','w'); f.write('this is the working directory'); f.close()"', (error, stdout, stderr) => { if (error) { console.error(exec error: ${error}
); return; } console.log(stdout: ${stdout}
); console.log(stderr: ${stderr}
); });| If that works do the same with the python command and try to find the |findme2.txt|.Last but not least, you can try to change the working directory in this line https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/blob/master/node_helper.js#L175.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/issues/20#issuecomment-252729134, or mute the thread https://github.com/notifications/unsubscribe-auth/AVky4KAB_k-WVcgsT9Q3odtX2HbdHWMZks5qypeIgaJpZM4KO-GZ.
Sebastian Merkel Kellerbergstraße 30 84030 Landshut
+49 (0) 871 95352675 +49 (0) 160 94646736
sebastian.merkel@gmail.com sebastian.merkel@zoho.com
Hi Sebastian,
yea I probably made a mistake in the snippet. However the working directory seems fine and the problem seems to be, it does not find the python command (if it does throw error on python --version
).
Therefore, I guess your PATH
variable is somehow different, when calling commands from node. Can you swap the command executed to this?
exec('(echo $PATH && which python) > output.txt', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});
And check the contents of the output.txt
file? My guess is, it will look like this:
[what is in the first line? something like /usr/local/bin:/usr/sbin:/usr/bin?]
python not found
If so, please run the command (echo $PATH && which python) > output.txt
on your regular command line, and compare both results.
If a messed up PATH
is the problem, I will add a config option to specify environment variables, and there you can put a specific one, which works for you.
Regards, Joseph
Have you considered using https://github.com/extrabacon/python-shell/blob/master/README.md? Seems a lot better than spawning python subprocess via a shell, I am using it in my facial recognition module.
Hi Joseph,
I tried you execution command:
exec('(echo $PATH && which python) > output.txt', (error, stdout,
stderr) => {
if (error) {
console.error(exec error: ${error}
);
return;
}
console.log(stdout: ${stdout}
);
console.log(stderr: ${stderr}
);
});
the file in pi@magicmirror:/var/www/html/MagicMirror/modules/MMM-FRITZ-Box-Callmonitor/output.txt
was created and
cat output.txt
says
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /usr/bin/python
Should be fine I guess. Am I wrong?
Cheers
Sebastian
Hi Sebastian,
yea I probably made a mistake in the snippet. However the working directory seems fine and the problem seems to be, it does not find the python command (if it does throw error on |python --version|).
Therefore, I guess your |PATH| variable is somehow different, when calling commands from node. Can you swap the command executed to this?
exec('(echo $PATH && which python) > output.txt', (error, stdout, stderr) => { if (error) { console.error(
exec error: ${error}
); return; } console.log(stdout: ${stdout}
); console.log(stderr: ${stderr}
); });And check the contents of the |output.txt| file? It should somehow look like this:
My guess is, it will look like this:
|[is something here?] python not found |
If so, please run the command (|(echo $PATH && which python) > output.txt|) on your regular command line, and compare both results.
If a messed up |PATH| is the problem, I will add a config option to specify environment variables, and there you can put a specific one, which works for you.
Regards, Joseph
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/issues/20#issuecomment-253149275, or mute the thread https://github.com/notifications/unsubscribe-auth/AVky4IBjbvdJjxdA8pgbQnXP3Weskg1zks5qzJglgaJpZM4KO-GZ.
Sebastian Merkel Kellerbergstraße 30 84030 Landshut
+49 (0) 871 95352675 +49 (0) 160 94646736
sebastian.merkel@gmail.com sebastian.merkel@zoho.com
Hi Joseph & paviro, python-shell maybe the better option to execute the .py script from js. Regrettably I can't be a big help since I'm a complete noob on js and python; but I'm motivated to solve this. ;-)
Hi Sebastian,
Did you have any luck? You could give my changes on #22 a try (need to npm install
the python-shell
dependency), and enable debug: true
in the config and see what kind of errors you get now in your logs.
Best regards Joseph
Hi Joseph,
Hi Sebastian,
Did you have any luck? You could give my changes on #22
No I tried some variations but always ended up in the matter, that the current node installation is not able to run .py code.
https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/pull/22 a try (need to |npm install| the |python-shell| dependency), and enable |debug: true| in the config and see what kind of errors you get now in your logs.
Ok. THe next days I do a pull and checkout the changes. I saw you implemented the python-shell ;-)
Best regards Joseph
Cheers
Sebastian
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/issues/20#issuecomment-257096918, or mute the thread https://github.com/notifications/unsubscribe-auth/AVky4PN9ukLucQQYeMl8fVGmLUyy31mLks5q42JDgaJpZM4KO-GZ.
Sebastian Merkel Kellerbergstraße 30 84030 Landshut
+49 (0) 871 95352675 +49 (0) 160 94646736
sebastian.merkel@gmail.com sebastian.merkel@zoho.com
Hi Joseph, your current changes in MMM-FRITZ-Box-Callmonitor did work out of the box. Great job! I connected to the fritzbox by using the dns name space fritz.box and as port 49000 with username and password. Also I switched the log level to debug:
Loading config ... Loading module helpers ... No helper found for module: alert. No helper found for module: clock. No helper found for module: currentweather. No helper found for module: weatherforecast. Initializing new module helper ... Initializing new module helper ... No helper found for module: MMM-Callmonitor-Current-Call. No helper found for module: MMM-iHaveBeenThere. Initializing new module helper ... All module helpers loaded. Starting server op port 8080 ... Server started ... Connecting socket for: MMM-FRITZ-Box-Callmonitor Starting module: MMM-FRITZ-Box-Callmonitor Connecting socket for: calendar Starting node helper for: calendar Connecting socket for: MMM-Stock MMM-Stock helper method started... Sockets connected & modules started ...
Ready to go! Please point your browser to: http://localhost:8080 Create new calendar fetcher for url: http://localhost/~pi/cal_import/pub_trashcollection.ics - Interval: 300000 Received config for MMM-FRITZ-Box-Callmonitor MMM-FRITZ-Box-Callmonitor is waiting for incoming calls. Starting access to FRITZ!Box... Create new calendar fetcher for url: http://localhost/~pi/cal_import/cal_main.ics - Interval: 300000 Create new calendar fetcher for url: http://localhost/~pi/cal_import/cal_birthdays.ics - Interval: 300000 Create new calendar fetcher for url: http://localhost/~pi/cal_import/pub_holidays.ics - Interval: 300000 Access to FRITZ!Box finished. Starting access to FRITZ!Box... Access to FRITZ!Box finished.
So far so good. MMM-FRITZ-Box-Callmonitor updates the recent calls. Also I use MMM-Callmonitor-Current-Call. But there seems to be a little problem. When I do a call from my mobile phone I hear the phone ringing downstairs. After ringing 2 minutes I hang up and MMM-FRITZ-Box-Callmonitor updates the call list. However I don't see the incoming call on the screen. Seems the communication between MMM-Callmonitor-Current-Call and MMM-FRITZ-Box-Callmonitor might somehow be interrupted or not working. Maybe I don't understand something in general: On the git page of https://github.com/paviro/MMM-FRITZ-Box-Callmonitor I see the incoming call picture but the description does not say anything about the display of the current incoming call. Thats why I think to display this, one needs MMM-Callmonitor-Current-Call. Am I right?
Cheers
Sebastian
Hi Sebastian,
Did you have any luck? You could give my changes on #22 https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/pull/22 a try (need to |npm install| the |python-shell| dependency), and enable |debug: true| in the config and see what kind of errors you get now in your logs.
Best regards Joseph
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/issues/20#issuecomment-257096918, or mute the thread https://github.com/notifications/unsubscribe-auth/AVky4PN9ukLucQQYeMl8fVGmLUyy31mLks5q42JDgaJpZM4KO-GZ.
Sebastian Merkel Kellerbergstraße 30 84030 Landshut
+49 (0) 871 95352675 +49 (0) 160 94646736
sebastian.merkel@gmail.com sebastian.merkel@zoho.com
Hi Sebastian,
did you change the fritzPort
in the config? Please remove it and see if that works (the default value of 1012
is probably correct). The 49000
is the port of the TR064 API and does not belong in the config (currently).
For clarification, if you get a call, the modules should do the following:
Best Regards Joseph
Hi Joseph,
Hi Sebastian,
you changed the |fritzPort| in the config? Please remove it and see if that works. That port is for the actual callmonitor, and should not be |49000|.
Yes I read somewhere in the www (guess it was avm itselve) with the 7490 one should use this port for collecting the data. Since it worked in the shell and with the .py script I left it on 49000. However the defaut port works as well with the MMModule.
For clarification, if you get a call, the modules should do the following:
- MMM-FRITZ-Box-Callmonitor displays alert while the phone rings
- MMM-Callmonitor-Current-Call displays the ongoing call, until it disconnects
- MMM-FRITZ-Box-Callmonitor adds missed calls after a call is disconnected
Thx 4 this information. With your latest python-shell implementation and the default port on the fritz.box I did not have any issues no more. ;-) Great job. Working fine even with the manual nodejs installation.
Cheers
Sebastian
Best Regards Joseph
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/paviro/MMM-FRITZ-Box-Callmonitor/issues/20#issuecomment-257160377, or mute the thread https://github.com/notifications/unsubscribe-auth/AVky4BNqTQvFkYSKM9L0h1z4IqFguOW1ks5q5MGjgaJpZM4KO-GZ.
Sebastian Merkel Kellerbergstraße 30 84030 Landshut
+49 (0) 871 95352675 +49 (0) 160 94646736
sebastian.merkel@gmail.com sebastian.merkel@zoho.com
Hi Sebastian,
in my edited answer I also tried to point out that there are two different ports involved, but only one is in the config (however neither of these will probably ever change, but who knows), so this is probably where the confusion came from. Glad it works now, I guess @paviro can close the issue then.
Best regards, Joseph
IsState: Raspberry Pi B+, Debian Jessie, running https://github.com/MichMich/MagicMirror node --version --> v6.6.0 Installation of MMM-FRITZ-Box-Callmonitor module like in description.
Complete error message: Whoops! There was an uncaught exception... { Error: spawn /bin/sh ENOENT at exports._errnoException (util.js:1036:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32) at onErrorNT (internal/child_process.js:359:16) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9) code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn /bin/sh', path: '/bin/sh', spawnargs: [ '-c', 'python fritz_access.py -d data -p MyPassword -u MyUser' ], cmd: 'python fritz_access.py -d data -p MyPassword -u MyUser' } MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection? If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
Sooo I guess this is the right place to put the issue in cause this module causes the exception.
Via command shell I can run: python fritz_access.py -d data -u MyUser -p MyPassword -i fritz.box -P 49000 Working. I receive the xml file. So the access with the module fritz_access.py is working.
As far as I see, the complete python command does not include the ip address nor the port. Closer look at the node_helper.js file shows the problem in my opinion: loadDataFromAPI: function(){} does not contain the config parameters of port and ip address.
I added the parameters but still get the exception. Google helped out more or less. This exception is thrown when files/executives are missing in the call path. But thats only maybe a hint.
cd /usr/local/bin/node ls node -al node -> /home/pi/compile/node-v6.6.0-linux-armv6l/bin/node
Should be fine.......or not?