diff --git a/.travis.yml b/.travis.yml index 95ad0b73..a59d45d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,11 +25,11 @@ before_deploy: - npm run package -- --all - npm run package-node - cd $TRAVIS_BUILD_DIR/dist/open-stage-control-linux-x64/resources/app/server/ - - wget https://github.com/jean-emmanuel/open-stage-control-midi/releases/latest/download/osc-midi-linux && chmod +x osc-midi-linux + - wget https://github.com/jean-emmanuel/open-stage-control-midi/releases/latest/download/osc-midi-linux && chmod +x osc-midi-linux && echo "true" > osc-midi.json - cd $TRAVIS_BUILD_DIR/dist/open-stage-control-win32-x64/resources/app/server/ - - wget https://github.com/jean-emmanuel/open-stage-control-midi/releases/latest/download/osc-midi-windows.exe && chmod +x osc-midi-windows.exe + - wget https://github.com/jean-emmanuel/open-stage-control-midi/releases/latest/download/osc-midi-windows.exe && chmod +x osc-midi-windows.exe && echo "true" > osc-midi.json - cd $TRAVIS_BUILD_DIR/dist/open-stage-control-darwin-x64/open-stage-control.app/Contents/Resources/app/server - - wget https://github.com/jean-emmanuel/open-stage-control-midi/releases/latest/download/osc-midi-osx && chmod +x osc-midi-osx + - wget https://github.com/jean-emmanuel/open-stage-control-midi/releases/latest/download/osc-midi-osx && chmod +x osc-midi-osx && echo "true" > osc-midi.json - cd $TRAVIS_BUILD_DIR - npm run deb64 - cd dist diff --git a/CHANGELOG.md b/CHANGELOG.md index 50679eb4..950de394 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ - bug fixes - matrix: regression from 1.9.8 (broken nested @{} syntax in props property) +- misc + - midi: detect missing binary (eg when deleted by antivirus) and print a message + ## 1.9.9 - bug fixes diff --git a/src/server/midi.js b/src/server/midi.js index f0657e6c..ba0cd4c6 100644 --- a/src/server/midi.js +++ b/src/server/midi.js @@ -18,11 +18,19 @@ var midiBinaries = { win32: 'osc-midi-windows.exe' } +var expectMidiBinaries = false, + expectMidiBinariesError = false; +try { + expectMidiBinaries = eval('require("./osc-midi.json")'); +} catch(e) {} + var pythonPathOverride if (process.arch === 'x64' && midiBinaries[process.platform]) { var p = path.resolve(__dirname, midiBinaries[process.platform]) if (fs.existsSync(p)) { pythonPathOverride = p + } else if (expectMidiBinaries) { + expectMidiBinariesError = true; } } @@ -30,6 +38,8 @@ class MidiConverter { constructor() { + if (expectMidiBinariesError) MidiConverter.midiBinariesError() + this.py = new PythonShell('python/midi.py', Object.assign({ args: [ '--params', @@ -112,6 +122,8 @@ class MidiConverter { static list() { + if (expectMidiBinariesError) MidiConverter.midiBinariesError() + PythonShell.run('python/midi.py', Object.assign({pythonPath: MidiConverter.getPythonPath(), args: ['--params', 'list-only']}, pythonOptions), function(e, results) { if (e) { if (e.code === 'ENOENT') { @@ -138,6 +150,14 @@ class MidiConverter { } + static midiBinariesError() { + + console.error(`(ERROR, MIDI) Could not find midi binary file ${p}\nIt may have been deleted by your antivirus.`) + console.log(`(INFO, MIDI) Falling back to python implementation (see https://openstagecontrol.ammd.net/docs/midi/midi-configuration/).`) + expectMidiBinariesError = false + + } + } module.exports = MidiConverter