From b2397117c2215d96cb40899d95a9cdca47162926 Mon Sep 17 00:00:00 2001 From: Ian Mancini Date: Thu, 12 Mar 2020 16:38:14 -0300 Subject: [PATCH] Add process submodule and bash script --- .gitmodules | 3 +++ index.js | 11 +++++++---- process | 1 + runProcess.sh | 5 +++++ 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .gitmodules create mode 160000 process create mode 100755 runProcess.sh diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5c82685 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "process"] + path = process + url = https://git.trovadores.duckdns.org/ianmethyst/spy-camera-process.git diff --git a/index.js b/index.js index fa3103d..e4b54b5 100644 --- a/index.js +++ b/index.js @@ -41,11 +41,14 @@ app.post('/upload-photo', async (req, res) => { }; // move photo to uploads directory - const filepath = `./uploads/${photo.name}`; - photo.mv(filepath); + const filepath = `uploads/${photo.name}`; + await photo.mv(`./${filepath}`); - const python = spawnSync('python3', - ['./main.py', `${filepath}`, `${city}`, `${school}`, `${age}`]); + const python = spawnSync( + 'bash', + ['-e', './runProcess.sh', `../${filepath}`, `${city}`, `${school}`, `${age}`]); + console.log("stdout: ",python.stdout.toString('utf8')); + console.log("stderr: ",python.stderr.toString('utf8')); if (python.status === 0) { res.send({ diff --git a/process b/process new file mode 160000 index 0000000..12990ca --- /dev/null +++ b/process @@ -0,0 +1 @@ +Subproject commit 12990cac8d50b44db953d7b375e43c039029b5e7 diff --git a/runProcess.sh b/runProcess.sh new file mode 100755 index 0000000..c942ec1 --- /dev/null +++ b/runProcess.sh @@ -0,0 +1,5 @@ +#/bin/bash + +cd process +pipenv run python3 main.py "$1" "$2" "$3" "$4" +exit 0