Revert "Drop python2 support.". Closes #7005.

This reverts commit 7d030b4cd9.
This commit is contained in:
sledgehammer999 2017-07-06 01:07:09 +03:00
parent 247d07edb9
commit 7a478424cc
No known key found for this signature in database
GPG key ID: 6E4A2D025B7CC9A2
11 changed files with 1231 additions and 22 deletions

View file

@ -238,11 +238,14 @@ QPoint Utils::Misc::screenCenter(const QWidget *w)
int Utils::Misc::pythonVersion()
{
static int version = -1;
if (version != 3) {
if (version < 0) {
QString versionComplete = pythonVersionComplete().trimmed();
QStringList splitted = versionComplete.split('.');
if (splitted.size() > 1)
version = splitted.at(0).toInt();
if (splitted.size() > 1) {
int highVer = splitted.at(0).toInt();
if ((highVer == 2) || (highVer == 3))
version = highVer;
}
}
return version;
}
@ -265,6 +268,11 @@ QString Utils::Misc::pythonExecutable()
executable = "python3";
return executable;
}
pythonProc.start("python2", QStringList() << "--version", QIODevice::ReadOnly);
if (pythonProc.waitForFinished() && (pythonProc.exitCode() == 0)) {
executable = "python2";
return executable;
}
#endif
// Look for "python" in Windows and in UNIX if "python2" and "python3" are
// not detected.