【发布时间】:2021-04-29 15:01:01
【问题描述】:
(抱歉我的英语不好),我正在制作一个魔镜并为此开发一个模块。我在 python 中完成了一个脚本,我需要不断地打印脚本的外壳,因为它是“While True”。为此,我需要做一个子进程,但我的问题是:当我的脚本运行时,它不会在日志控制台或镜像中打印任何内容。
node_helper.js的文件--->
var NodeHelper = require("node_helper")
var { spawn } = require("child_process")
var self = this
async function aexec() {
const task = spawn('python3', ['/Fotos/reconeixementfacial.py'])
task.stdout.on('data', (data) => {
console.log(`${data}`)
})
task.stdout.on('exit', (data) => {
console.log("exit")
})
task.stdout.on('error', (data) => {
console.log(`${error}`)
})
task.unref()
}
module.exports = NodeHelper.create({
start: function() {
aexec()
},
socketNotificationReceived: function(notification, payload) {
console.log(notification)
}
})
非常感谢您抽出宝贵的时间!! 注意:如果我的 python 脚本没有“while true”(只有一个序列),它可以工作,只有在我的脚本未定义时才有效
【问题讨论】:
标签: javascript python magic-mirror