Commit 49d2d066 authored by Julius Künzel's avatar Julius Künzel
Browse files

[otio] In case of an error check if it is due to the installed version

parent c856dedf
Pipeline #124981 passed with stage
in 6 minutes and 48 seconds
......@@ -49,6 +49,14 @@ PythonDependencyMessage::PythonDependencyMessage(QWidget *parent, AbstractPython
doShowMessage(messages.join(QStringLiteral("\n")), KMessageWidget::Warning);
});
connect(m_interface, &AbstractPythonInterface::proposeUpdate, this, [&](const QString &message){
// only allow upgrading python modules once
m_installAction->setText(i18n("Check for update"));
m_installAction->setEnabled(true);
addAction(m_installAction);
doShowMessage(message, KMessageWidget::Warning);
});
connect(m_interface, &AbstractPythonInterface::dependenciesAvailable, this, [&](){
if (!m_updated) {
// only allow upgrading python modules once
......@@ -100,6 +108,7 @@ void PythonDependencyMessage::doShowMessage(const QString &message, KMessageWidg
AbstractPythonInterface::AbstractPythonInterface(QObject *parent)
: QObject{parent}
, m_dependencies()
, m_versions(new QMap<QString, QString>())
, m_scripts(new QMap<QString, QString>())
{
addScript(QStringLiteral("checkpackages.py"));
......@@ -202,7 +211,30 @@ void AbstractPythonInterface::updateDependencies() {
runPackageScript(QStringLiteral("--upgrade"));
}
void AbstractPythonInterface::checkVersions()
void AbstractPythonInterface::proposeMaybeUpdate(const QString &dependency, const QString &minVersion)
{
checkVersions(false);
QString currentVersion = m_versions->value(dependency);
if (currentVersion.isEmpty()) {
emit setupError(i18n("Error while checking version of module %1", dependency));
return;
}
if (versionToInt(currentVersion) < versionToInt(minVersion)) {
emit proposeUpdate(i18n("At least version %1 of module %2 is required, "
"but your current version is %3", minVersion, dependency, currentVersion));
} else {
emit proposeUpdate(i18n("Please consider to update your setup."));
}
}
int AbstractPythonInterface::versionToInt(const QString &version) {
QStringList v = version.split(QStringLiteral("."));
return QT_VERSION_CHECK(v.length() > 0 ? v.at(0).toInt() : 0,
v.length() > 1 ? v.at(1).toInt() : 0,
v.length() > 2 ? v.at(2).toInt() : 0);
}
void AbstractPythonInterface::checkVersions(bool signalOnResult)
{
QString output = runPackageScript(QStringLiteral("--details"));
if (output.isEmpty()) {
......@@ -221,9 +253,16 @@ void AbstractPythonInterface::checkVersions()
QString version = raw.at(i+1);
version = version.simplified().section(QLatin1Char(' '), 0, 0);
versions.append(QString("%1 %2").arg(name, version));
if (m_versions->contains(name)) {
(*m_versions)[name.toLower()] = version;
} else {
m_versions->insert(name.toLower(), version);
}
}
}
emit checkVersionsResult(versions);
if (signalOnResult) {
emit checkVersionsResult(versions);
}
}
QString AbstractPythonInterface::runPackageScript(const QString &mode) {
......
......@@ -17,13 +17,34 @@ class AbstractPythonInterface : public QObject
Q_OBJECT
public:
explicit AbstractPythonInterface(QObject *parent = nullptr);
/** @brief Check if python and pip are installed, as well as all required scripts.
If a check failed setupError() will be emitted with an error message that can be
shown to the user.
@returns wether all checks succeeded.
*/
bool checkSetup();
/** @brief Check if all dependencies are installed.
If everything is okay dependenciesAvailable() will be emitted,
otherwise dependenciesMissing() with a message that can be shown
to the user telling wich dependencies are missing.
To get a list of all missing dependencies use missingDependencies
@returns wether all checks succeeded.
*/
void checkDependencies();
void checkVersions();
/** @brief Check which versions of the dependencies are installed.
@param Whether checkVersionsResult() will be emitted once the result is available.
*/
void checkVersions(bool signalOnResult = true);
void updateDependencies();
/** @brief Returns a cached list of all missing dependencies
* To update the cache run checkDependencies().
* @param filter If this is empty all missing packages will be returned,
* otherwise only those of the filter (in case they are missing).
*/
QStringList missingDependencies(const QStringList &filter = {});
QString runScript(const QString &scriptpath, QStringList args = {}, const QString &firstarg = {});
QString pythonExec() { return m_pyExec; };
void proposeMaybeUpdate(const QString &dependency, const QString &minVersion);
friend class PythonDependencyMessage;
......@@ -32,10 +53,12 @@ private:
QString m_pip3Exec;
QMap<QString, QString> m_dependencies;
QStringList m_missing;
QMap<QString, QString> *m_versions;
void installMissingDependencies();
QString locateScript(const QString &script);
QString runPackageScript(const QString &mode);
int versionToInt(const QString &version);
protected:
QMap<QString, QString> *m_scripts;
......@@ -48,6 +71,7 @@ signals:
void checkVersionsResult(const QStringList &versions);
void dependenciesMissing(const QStringList &messages);
void dependenciesAvailable();
void proposeUpdate(const QString &message);
};
......
......@@ -28,8 +28,18 @@ OtioConvertions::OtioConvertions()
}
m_importAdapters = runScript(QStringLiteral("otiointerface.py"), {"--import-suffixes"});
qInfo() << "OTIO import adapters:" << m_importAdapters;
m_exportAdapters = runScript(QStringLiteral("otiointerface.py"), {"--export-suffixes"});
qInfo() << "OTIO export adapters:" << m_exportAdapters;
if (!m_importAdapters.isEmpty()) {
// no error occured so we can check export adapters as well
m_exportAdapters = runScript(QStringLiteral("otiointerface.py"), {"--export-suffixes"});
qInfo() << "OTIO export adapters:" << m_exportAdapters;
}
if (m_importAdapters.isEmpty() || m_exportAdapters.isEmpty()) {
// something is wrong. Maybe it is related to an old version?
proposeMaybeUpdate("opentimelineio", "0.14.0");
// versions < 0.14.0 do not work on windows properly
// see https://github.com/PixarAnimationStudios/OpenTimelineIO/issues/813
return;
}
if (!(m_exportAdapters.contains("kdenlive") && m_importAdapters.contains("kdenlive"))) {
emit setupError(i18n("Your OpenTimelineIO module does not include Kdenlive adapter.\n"
"Please install version >= 0.12\n"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment