Mercurial > hg > svcore
changeset 1563:175ef02c7864
Merge
author | Chris Cannam |
---|---|
date | Fri, 02 Nov 2018 14:41:00 +0000 (2018-11-02) |
parents | 830972646ccd (current diff) d3814e07b8aa (diff) |
children | 5f9c9d8c3de6 f6e7d0e783e8 |
files | |
diffstat | 4 files changed, 78 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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; }
--- 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<QString> PiperVampPluginFactory::getPluginIdentifiers(QString &errorMessage) {
--- 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<QString, piper_vamp::PluginStaticData> m_pluginData; // identifier -> data std::map<QString, QString> m_taxonomy; // identifier -> category string + bool serverMeetsMinimumVersion(const HelperExecPath::HelperExec &server, + float minimumVersion); void populate(QString &errorMessage); void populateFrom(const HelperExecPath::HelperExec &, QString &errorMessage);