{
"name": "MMMTestpython",
"description": "samples",
"version": "0.0.1",
"dependencies": {
"python-shell": "latest"
}
}
Do I have to change it like this and install it again? npm install
{
"name": "MMMTestpython",
"description": "samples",
"version": "0.0.1",
"dependencies": {
"python-shell": "latest"
}
}
Do I have to change it like this and install it again? npm install
@sdetweil oh!!!
thank you very very very much :)
@sdetweil said in Even a simple node_help.js example does not run.:
console.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
var NodeHelper = require("node_helper");
//var {PythonShell} = require('python-shell');
module.exports = NodeHelper.create({
start: function() {},
socketNotificationReceived: function(notification, payload) {
console.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
},
})
omg…
Is it normal for these errors to occur?
/modules/MMM-Testpython/package.json
MMM-Testpython
var Testpythons;
Module.register("MMM-Testpython", {
defaults: {},
start: function (){
Testpythons = this;
},
getDom: function() {
var element = document.createElement("div")
element.className = "myContent"
element.id="divid"
element.innerHTML = "Hello, World!!! " + this.config.foo
var subElement = document.createElement("p")
subElement.innerHTML = "Click"
subElement.id = "clickid"
element.appendChild(subElement)
return element
},
notificationReceived: function(notification, payload, sender) {
switch(notification) {
case "DOM_OBJECTS_CREATED":
var elem = document.getElementById("clickid")
elem.addEventListener("click", () => {
Testpythons.sendSocketNotification("TEST")
console.log("hello~hello~hello~hello~hello~hello~hello~hello~hello~hello~")
elem.innerHTML = "click success"
})
break
}
},
})
node_helper.js
var NodeHelper = require("node_helper");
var {PythonShell} = require('python-shell');
module.exports = NodeHelper.create({
start: function() {},
socketNotificationReceived: function(notification, payload) {
switch(notification) {
case "TEST":
console.log("notification : " + notification)
this.sendSocketNotification("I_DID")
break
}
},
})
The notification I_DID in node_helper.js was well communicated and executed. However, the console in node_helper.js is not output…
What is the problem?
var NodeHelper = require("node_helper");
var {PythonShell} = require('python-shell');
module.exports = NodeHelper.create({
start: function() {},
socketNotificationReceived: function(notification, payload) {
Log.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
},
})
Even a simple node_help.js example does not run.
var NodeHelper = require("node_helper");
var {PythonShell} = require('python-shell');
module.exports = NodeHelper.create({
start: function() {
console.log("Starting module: " + this.name);
},
socketNotificationReceived: function(notification, payload) {
console.log("Starting module: " + this.name);
switch(notification) {
case "TESTPYTHON":
console.log("notification : " + notification)
this.sendSocketNotification("I_DID")
PythonShell.runString('print("Hello Python")', null, function (err, result) {
if (err) throw err;
console.log(result);
});
break
}
},
})
console doesnt show Starting module…
I tried to use python-shell. So I successfully finished the npm install python-shell.
But I saw it said that to use python-shell, you must use node_helper.js.
So I tried to execute a simple Python code. The notification I_DID in node_helper.js was well communicated and executed. However, the console in node_helper.js is not output, nor is python-shell working.
What is the problem?
var Testpythons;
Module.register("MMM-Testpython", {
defaults: {},
start: function (){
Testpythons = this;
},
getDom: function() {
var element = document.createElement("div")
element.className = "myContent"
element.id="divid"
element.innerHTML = "Hello, World!!! " + this.config.foo
var subElement = document.createElement("p")
subElement.innerHTML = "Click"
subElement.id = "clickid"
element.appendChild(subElement)
return element
},
notificationReceived: function(notification, payload, sender) {
switch(notification) {
case "DOM_OBJECTS_CREATED":
var elem = document.getElementById("clickid")
elem.addEventListener("click", () => {
Testpythons.sendSocketNotification("TESTPYTHON")
console.log("hello~hello~hello~hello~hello~hello~hello~hello~hello~hello~")
elem.innerHTML = "click success"
})
break
}
},
socketNotificationReceived: function(notification, payload) {
switch(notification) {
case "I_DID":
console.log("success")
var elemk = document.getElementById("divid")
elemk.innerHTML = "I_DID"
break
}
},
})
node_helper.js
var NodeHelper = require("node_helper");
var PythonShell = require('python-shell');
module.exports = NodeHelper.create({
start: function() {
console.log("Starting module: " + this.name);
},
socketNotificationReceived: function(notification, payload) {
switch(notification) {
case "TESTPYTHON":
console.log("notification : " + notification)
this.sendSocketNotification("I_DID")
PythonShell.runString('print("Hello Python")', null, function (err, result) {
if (err) throw err;
console.log(result);
});
break
}
},
})