1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Recognize pip installs of RPi.GPIO (#1934)

Fixes "[warn] rpi-gpio : Cannot find Pi RPi.GPIO python library" when it is installed with pip using the default prefix (/usr/local).
This commit is contained in:
Nephiel 2018-10-24 00:20:44 +02:00 committed by Dave Conway-Jones
parent 19b6cba398
commit 4f87ebdf0a

View File

@ -23,12 +23,16 @@ module.exports = function(RED) {
} catch(err) { } catch(err) {
try { try {
fs.statSync("/usr/lib/python2.7/dist-packages/RPi/GPIO"); // test on Hypriot fs.statSync("/usr/lib/python2.7/dist-packages/RPi/GPIO"); // test on Hypriot
} catch(err) {
try {
fs.statSync("/usr/local/lib/python2.7/dist-packages/RPi/GPIO"); // installed with pip
} catch(err) { } catch(err) {
RED.log.warn("rpi-gpio : "+RED._("rpi-gpio.errors.libnotfound")); RED.log.warn("rpi-gpio : "+RED._("rpi-gpio.errors.libnotfound"));
allOK = false; allOK = false;
} }
} }
} }
}
if ( !(1 & parseInt((fs.statSync(gpioCommand).mode & parseInt("777", 8)).toString(8)[0]) )) { if ( !(1 & parseInt((fs.statSync(gpioCommand).mode & parseInt("777", 8)).toString(8)[0]) )) {
RED.log.warn("rpi-gpio : "+RED._("rpi-gpio.errors.needtobeexecutable",{command:gpioCommand})); RED.log.warn("rpi-gpio : "+RED._("rpi-gpio.errors.needtobeexecutable",{command:gpioCommand}));
allOK = false; allOK = false;