0
私はPythonスクリプトを実行することができますが、実際にはPythonスクリプトでファイルを保存することに問題があります。ターミナルから直接Pythonスクリプトを実行すると、ノードプロセスを起動するときにファイルが黙って失敗するように見えます(ファイルは保存されないため、ノードスクリプトは失敗します)。 Pythonスクリプトを直接実行すると権限や場所の問題になるのでしょうか?ノードからPythonスクリプトを実行してファイルを保存する
私はpython-shellを使用して処理を容易にしています。私はos.getcwd()
とpythonでスクリプトの場所を確認し、ファイルの保存とノードの間に十分な時間があることを確認するsleep
コマンドを実行しようとしてい
router.get('/patientsExport', (req, res) => {
const options = {
mode: 'text',
scriptPath: __dirname,
};
PythonShell.run('patientsExport.py', options, err => {
if (err) {
logger.error(err);
throw err;
}
const filePath = path.join(__dirname, 'patientsExport.xlsx');
fs.exists(filePath, exists => {
if (exists) {
// Deliver the file
} else {
res.writeHead(400, { 'Content-Type': 'text/plain' });
res.end('ERROR File does NOT Exists');
}
});
});
});
:私の現在のAPIエンドポイントは、このようなものですそれを見つけるが、役に立たない。
wb.save(filename=dest_filename)
while not exists(dest_filename):
sleep(1)
誰でもこれについての経験があるか、間違っていることを知っていますか?