# HG changeset patch # User Chris Cannam # Date 1541169660 0 # Node ID 175ef02c7864d91a22f8458d1c0ac922d2314682 # Parent 830972646ccd80e3d2694d5bee381c4d11ef0da5# Parent d3814e07b8aa5fb5e036c061c93e9ec08ac7a8d0 Merge diff -r 830972646ccd -r 175ef02c7864 data/model/AlignmentModel.cpp --- a/data/model/AlignmentModel.cpp Fri Nov 02 14:40:44 2018 +0000 +++ b/data/model/AlignmentModel.cpp Fri Nov 02 14:41:00 2018 +0000 @@ -101,10 +101,16 @@ { if (!m_pathBegun && m_rawPath) { if (completion) *completion = 0; +#ifdef DEBUG_ALIGNMENT_MODEL + SVDEBUG << "AlignmentModel::isReady: path not begun" << endl; +#endif return false; } if (m_pathComplete) { if (completion) *completion = 100; +#ifdef DEBUG_ALIGNMENT_MODEL + SVDEBUG << "AlignmentModel::isReady: path complete" << endl; +#endif return true; } if (!m_rawPath) { @@ -112,6 +118,9 @@ // m_pathComplete true above) or else no alignment has been // set at all yet (this case) if (completion) *completion = 0; +#ifdef DEBUG_ALIGNMENT_MODEL + SVDEBUG << "AlignmentModel::isReady: no raw path" << endl; +#endif return false; } return m_rawPath->isReady(completion); @@ -381,6 +390,7 @@ if (m_path) m_path->aboutToDelete(); delete m_path; m_path = path; + m_pathComplete = true; #ifdef DEBUG_ALIGNMENT_MODEL cerr << "AlignmentModel::setPath: path = " << m_path << endl; #endif diff -r 830972646ccd -r 175ef02c7864 data/model/Model.cpp --- a/data/model/Model.cpp Fri Nov 02 14:40:44 2018 +0000 +++ b/data/model/Model.cpp Fri Nov 02 14:41:00 2018 +0000 @@ -161,14 +161,15 @@ int Model::getAlignmentCompletion() const { -// SVDEBUG << "Model::getAlignmentCompletion" << endl; +// SVDEBUG << "Model::getAlignmentCompletion: m_alignment = " +// << m_alignment << endl; if (!m_alignment) { if (m_sourceModel) return m_sourceModel->getAlignmentCompletion(); else return 100; } int completion = 0; (void)m_alignment->isReady(&completion); -// cerr << " -> " << completion << endl; +// SVDEBUG << " -> " << completion << endl; return completion; } diff -r 830972646ccd -r 175ef02c7864 plugin/PiperVampPluginFactory.cpp --- a/plugin/PiperVampPluginFactory.cpp Fri Nov 02 14:40:44 2018 +0000 +++ b/plugin/PiperVampPluginFactory.cpp Fri Nov 02 14:41:00 2018 +0000 @@ -58,18 +58,29 @@ m_logger(new Logger) { QString serverName = "piper-vamp-simple-server"; + float minimumVersion = 2.0; HelperExecPath hep(HelperExecPath::AllInstalled); - m_servers = hep.getHelperExecutables(serverName); - for (auto n: m_servers) { + auto servers = hep.getHelperExecutables(serverName); + + for (auto n: servers) { SVDEBUG << "NOTE: PiperVampPluginFactory: Found server: " << n.executable << endl; + if (serverMeetsMinimumVersion(n, minimumVersion)) { + m_servers.push_back(n); + } else { + SVCERR << "WARNING: PiperVampPluginFactory: Server at " + << n.executable + << " does not meet minimum version requirement (version >= " + << minimumVersion << ")" << endl; + } } if (m_servers.empty()) { SVDEBUG << "NOTE: No Piper Vamp servers found in installation;" - << " found none of the following:" << endl; + << " the following paths are either absent or fail " + << "minimum-version check:" << endl; for (auto d: hep.getHelperCandidatePaths(serverName)) { SVDEBUG << "NOTE: " << d << endl; } @@ -81,6 +92,55 @@ delete m_logger; } +bool +PiperVampPluginFactory::serverMeetsMinimumVersion(const HelperExecPath::HelperExec &server, + float minimumVersion) +{ + QProcess process; + QString executable = server.executable; + process.setReadChannel(QProcess::StandardOutput); + process.setProcessChannelMode(QProcess::ForwardedErrorChannel); + process.start(executable, { "--version" }); + + if (!process.waitForStarted()) { + QProcess::ProcessError err = process.error(); + if (err == QProcess::FailedToStart) { + SVCERR << "WARNING: Unable to start server " << executable + << " for version check" << endl; + } else if (err == QProcess::Crashed) { + SVCERR << "WARNING: Server " << executable + << " crashed on version check" << endl; + } else { + SVCERR << "WARNING: Server " << executable + << " failed on version check with error code " + << err << endl; + } + return false; + } + process.waitForFinished(); + + QByteArray output = process.readAllStandardOutput(); + while (output.endsWith('\n') || output.endsWith('\r')) { + output.chop(1); + } + + QString outputString(output); + bool ok = false; + float version = outputString.toFloat(&ok); + if (!ok) { + SVCERR << "WARNING: Failed to convert server version response \"" + << outputString << "\" into one- or two-part version number" + << endl; + } + + SVDEBUG << "Server " << executable << " reports version number " + << version << endl; + + float eps = 1e-6; + return (version >= minimumVersion || + fabsf(version - minimumVersion) < eps); // arf +} + vector PiperVampPluginFactory::getPluginIdentifiers(QString &errorMessage) { diff -r 830972646ccd -r 175ef02c7864 plugin/PiperVampPluginFactory.h --- a/plugin/PiperVampPluginFactory.h Fri Nov 02 14:40:44 2018 +0000 +++ b/plugin/PiperVampPluginFactory.h Fri Nov 02 14:41:00 2018 +0000 @@ -59,6 +59,8 @@ std::map m_pluginData; // identifier -> data std::map m_taxonomy; // identifier -> category string + bool serverMeetsMinimumVersion(const HelperExecPath::HelperExec &server, + float minimumVersion); void populate(QString &errorMessage); void populateFrom(const HelperExecPath::HelperExec &, QString &errorMessage);