Browse Source

fix gphoto cwd

master
P.BARRY 7 years ago
parent
commit
c412f41bf7
4 changed files with 27 additions and 13 deletions
  1. 6
      index.js
  2. 2
      server/booth.js
  3. 12
      server/index.js
  4. 20
      tools/tools-gphoto2.js

6
index.js

@ -6,11 +6,11 @@ const args = require('args-parser')(process.argv)
const PKG = require('./package') const PKG = require('./package')
if (args.noinit) { if (args.noinit) {
let app = server()
let app = server(args)
} else { } else {
gphoto2.init(function (pErr) {
gphoto2.init(function () {
console.log('[>] Checking list done with success') console.log('[>] Checking list done with success')
let app = server()
let app = server(args)
}) })
} }

2
server/booth.js

@ -32,7 +32,7 @@ setGamepad()
router.get('/dslr/takepicture/:boothId/:pictId', function (req, res, next) { router.get('/dslr/takepicture/:boothId/:pictId', function (req, res, next) {
// return res.json({}) // return res.json({})
gphoto2.takeOnePicture(req.params.boothId, req.params.pictId, function (pErr) { 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) if (pErr) console.error(pErr)
res.json({ error: error, data: null }) res.json({ error: error, data: null })
}) })

12
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, () => { let server = app.listen(CFG.server.port, () => {
console.log(`[-] Server running on: ${CFG.server.ipAddress}:${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) app.locals.io = require('socket.io')(server)
booth.setSocketIo(app.locals.io) 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 return app
} }

20
tools/tools-gphoto2.js

@ -11,8 +11,18 @@ var CFG = require('../config')
let tools = {} 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) { if (pErr) {
console.log(`[!] Please install gphoto2`.red) console.log(`[!] Please install gphoto2`.red)
console.log(`sudo apt-get install gphoto2`.bgMagenta) console.log(`sudo apt-get install gphoto2`.bgMagenta)
@ -30,7 +40,7 @@ function execGphoto2 (pArgs, pCallback) {
if (pStdout) { if (pStdout) {
outInLines = splitLines(pStdout) outInLines = splitLines(pStdout)
} }
pCallback(error, outInLines)
callback(error, outInLines)
}) })
} }
@ -63,7 +73,9 @@ tools.checkCameraConnection = function (pCb) {
} }
tools.__takeOnePicture = function (pPath, 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) { tools.takeOnePicture = function (pBoothId, pPictId, pCallback) {

Loading…
Cancel
Save