From c412f41bf72b7d01819afde0bb5c8a27ced6f5d1 Mon Sep 17 00:00:00 2001 From: "P.BARRY" Date: Wed, 15 Aug 2018 23:05:04 +0200 Subject: [PATCH] fix gphoto cwd --- index.js | 6 +++--- server/booth.js | 2 +- server/index.js | 12 +++++++----- tools/tools-gphoto2.js | 20 ++++++++++++++++---- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index f811fa5..63720ef 100644 --- a/index.js +++ b/index.js @@ -6,11 +6,11 @@ const args = require('args-parser')(process.argv) const PKG = require('./package') if (args.noinit) { - let app = server() + let app = server(args) } else { - gphoto2.init(function (pErr) { + gphoto2.init(function () { console.log('[>] Checking list done with success') - let app = server() + let app = server(args) }) } diff --git a/server/booth.js b/server/booth.js index dc415ef..0960a27 100644 --- a/server/booth.js +++ b/server/booth.js @@ -32,7 +32,7 @@ setGamepad() router.get('/dslr/takepicture/:boothId/:pictId', function (req, res, next) { // return res.json({}) gphoto2.takeOnePicture(req.params.boothId, req.params.pictId, function (pErr) { - let error = typeof pErr === 'string' ? pErr : JSON.stringigy(pErr) + let error = typeof pErr === 'string' ? pErr : JSON.stringify(pErr) if (pErr) console.error(pErr) res.json({ error: error, data: null }) }) diff --git a/server/index.js b/server/index.js index edfd208..d1c8bf7 100644 --- a/server/index.js +++ b/server/index.js @@ -45,7 +45,7 @@ app.get('/bobinoscope', (req, res) => { }) }) -module.exports = function () { +module.exports = function (pArgs) { let server = app.listen(CFG.server.port, () => { console.log(`[-] Server running on: ${CFG.server.ipAddress}:${CFG.server.port}`) }) @@ -53,9 +53,11 @@ module.exports = function () { app.locals.io = require('socket.io')(server) booth.setSocketIo(app.locals.io) - console.log(`[-] Starting chromium...`) - opn('http://localhost:3111/bobinoscope', { - app: ['chromium-browser', '--app=http://localhost:3111/bobinoscope', '--start-fullscreen', '--password-store=basic'] - }) + if (!pArgs.noc) { + console.log(`[-] Starting chromium...`) + opn('http://localhost:3111/bobinoscope', { + app: ['chromium-browser', '--app=http://localhost:3111/bobinoscope', '--start-fullscreen', '--password-store=basic'] + }) + } return app } diff --git a/tools/tools-gphoto2.js b/tools/tools-gphoto2.js index c8c417f..b456c26 100644 --- a/tools/tools-gphoto2.js +++ b/tools/tools-gphoto2.js @@ -11,8 +11,18 @@ var CFG = require('../config') let tools = {} -function execGphoto2 (pArgs, pCallback) { - exec(`gphoto2 ${pArgs}`, function (pErr, pStdout, pStderr) { +function execGphoto2 (pArgs, pMore, pCallback) { + let args, more, callback + if (pCallback) { + args = pArgs + more = pMore + callback = pCallback + } else { + args = pArgs + more = {} + callback = pMore + } + exec(`gphoto2 ${args}`, more, function (pErr, pStdout, pStderr) { if (pErr) { console.log(`[!] Please install gphoto2`.red) console.log(`sudo apt-get install gphoto2`.bgMagenta) @@ -30,7 +40,7 @@ function execGphoto2 (pArgs, pCallback) { if (pStdout) { outInLines = splitLines(pStdout) } - pCallback(error, outInLines) + callback(error, outInLines) }) } @@ -63,7 +73,9 @@ tools.checkCameraConnection = function (pCb) { } tools.__takeOnePicture = function (pPath, pCb) { - execGphoto2(`--capture-image-and-download --filename=${pPath} --force-overwrite`, pCb) + let lPath = path.parse(pPath) + console.log(lPath) + execGphoto2(`--capture-image-and-download --filename=${lPath.base} --force-overwrite`, {cwd: lPath.dir}, pCb) } tools.takeOnePicture = function (pBoothId, pPictId, pCallback) {