From 9d40a529df51207bfe6a836388983bf0466c7615 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Thu, 28 Mar 2019 11:44:17 +0100 Subject: [PATCH] Update server.js --- server.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 23402d2..0e041ee 100644 --- a/server.js +++ b/server.js @@ -18,6 +18,26 @@ try { fs.mkdirSync(aisPathOld); } catch { } let pythonRunning = false; let pythonShouldRun = false; +function runPythonTotal() { + let p = spawn(pythonPath, ['run.py'], {cwd: 'pytron_run'}); + p.stdout.on('data', (data) => { + let content = data.toString().split('\n'); + for (let line of content) { + console.log('run.py: ' + line); + } + }); + + p.stderr.on('data', (data) => { + let content = data.toString().split('\n'); + for (let line of content) { + console.log('run.py: ' + line); + } + }); + + p.on('close', (code) => { + process.stdout.write('Python finished executing'); + }); +} function runPython() { process.stdout.write('Requested to run python'); if (pythonRunning) { @@ -317,12 +337,15 @@ function main() { case 'start': startServer(); break; - case 'python': + case 'refresh': runPython(); break; + case 'recompute': + runPythonTotal(); + break; default: console.log('Unknown option: ' + process.argv[2]); - console.log('Usage: node server.js start|python') + console.log('Usage: node server.js start|refresh|recompute') process.exit(1); break; }