mirror of
				https://github.com/node-red/node-red-nodes.git
				synced 2025-03-01 10:37:43 +00:00 
			
		
		
		
	Add runtime check for sensehat python libs
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|     "name"          : "node-red-node-pi-sense-hat", | ||||
|     "version"       : "0.0.8", | ||||
|     "version"       : "0.0.9", | ||||
|     "description"   : "A Node-RED node to interact with a Raspberry Pi Sense HAT", | ||||
|     "repository" : { | ||||
|         "type":"git", | ||||
|   | ||||
| @@ -22,9 +22,12 @@ module.exports = function(RED) { | ||||
|  | ||||
|     var hatCommand = __dirname+'/sensehat'; | ||||
|  | ||||
|     if ( !(1 & parseInt ((fs.statSync(hatCommand).mode & parseInt ("777", 8)).toString (8)[0]) )) { | ||||
|         RED.log.error(hatCommand + " command is not executable"); | ||||
|         throw "Error : "+RED._("node-red:rpi-gpio.errors.mustbeexecutable"); | ||||
|     if (!fs.existsSync('/usr/lib/python2.7/dist-packages/sense_hat')) { | ||||
|         throw "Error: Can't find Sense HAT python libraries. Run sudo apt-get install sense-hat"; | ||||
|     } | ||||
|  | ||||
|     if ( !(1 & parseInt((fs.statSync(hatCommand).mode & parseInt ("777", 8)).toString(8)[0]) )) { | ||||
|         throw "Error: "+RED._("node-red:rpi-gpio.errors.mustbeexecutable"); | ||||
|     } | ||||
|  | ||||
|     // the magic to make python print stuff immediately | ||||
|   | ||||
		Reference in New Issue
	
	Block a user