使用 NPM Python Shell 为 Electron 回调
Callback with NPM Python Shell for Electron
所以这是我的代码,我正在使用 python sheel 来执行读取 RFID 标签的 python 脚本。 python 脚本工作正常,但我的问题是我想在执行 python 脚本后 console.log("testing") (当我将标签放在 RFID 上时reader),而不是先在控制台记录 "testing",然后执行 python 脚本。有什么办法可以解决这个问题,回调什么的吗?
function getDadosPulseira(){
var {PythonShell} = require('python-shell')
var path = require('path')
var options = {
scriptPath: path.join(__dirname, '../_engine/')//,
}
var readrfid = new PythonShell('readtag.py', options)
readrfid.on("message", function(message) {
swal({
title: "Pulseira!",
text: message,
icon: "success",
timer: 3000
});
console.log(message);
})
console.log("testing");
}
async function getDadosPulseira() {
var {PythonShell} = require('python-shell')
var path = require('path')
var options = {
scriptPath: path.join(__dirname, '../_engine/')//,
}
var readrfid = new PythonShell('readtag.py', options)
readrfid.on("message", function(message) {
swal({
title: "Pulseira!",
text: message,
icon: "success",
timer: 3000
});
console.log(message);
})
readrfid.end(function (err) {
console.log("testing");
});
}
所以这是我的代码,我正在使用 python sheel 来执行读取 RFID 标签的 python 脚本。 python 脚本工作正常,但我的问题是我想在执行 python 脚本后 console.log("testing") (当我将标签放在 RFID 上时reader),而不是先在控制台记录 "testing",然后执行 python 脚本。有什么办法可以解决这个问题,回调什么的吗?
function getDadosPulseira(){
var {PythonShell} = require('python-shell')
var path = require('path')
var options = {
scriptPath: path.join(__dirname, '../_engine/')//,
}
var readrfid = new PythonShell('readtag.py', options)
readrfid.on("message", function(message) {
swal({
title: "Pulseira!",
text: message,
icon: "success",
timer: 3000
});
console.log(message);
})
console.log("testing");
}
async function getDadosPulseira() {
var {PythonShell} = require('python-shell')
var path = require('path')
var options = {
scriptPath: path.join(__dirname, '../_engine/')//,
}
var readrfid = new PythonShell('readtag.py', options)
readrfid.on("message", function(message) {
swal({
title: "Pulseira!",
text: message,
icon: "success",
timer: 3000
});
console.log(message);
})
readrfid.end(function (err) {
console.log("testing");
});
}