From 841676fd3639a18e769ef629ba22a49ffd594e96 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Tue, 1 Nov 2016 00:19:37 +0200 Subject: [PATCH] WINDOWS: Fix python auto install, deletion of installer and use 3.5.x series for Vista+. Closes #5871. --- src/gui/mainwindow.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index c46881344..f1020eee7 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -1749,7 +1750,11 @@ void MainWindow::installPython() { setCursor(QCursor(Qt::WaitCursor)); // Download python - Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl("https://www.python.org/ftp/python/3.4.3/python-3.4.3.msi", true); + Net::DownloadHandler *handler = nullptr; + if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) + handler = Net::DownloadManager::instance()->downloadUrl("https://www.python.org/ftp/python/3.5.2/python-3.5.2.exe", true); + else + handler = Net::DownloadManager::instance()->downloadUrl("https://www.python.org/ftp/python/3.4.4/python-3.4.4.msi", true); connect(handler, SIGNAL(downloadFinished(QString, QString)), this, SLOT(pythonDownloadSuccess(QString, QString))); connect(handler, SIGNAL(downloadFailed(QString, QString)), this, SLOT(pythonDownloadFailure(QString, QString))); } @@ -1758,19 +1763,29 @@ void MainWindow::pythonDownloadSuccess(const QString &url, const QString &filePa { Q_UNUSED(url) setCursor(QCursor(Qt::ArrowCursor)); - QFile::rename(filePath, filePath + ".msi"); QProcess installer; qDebug("Launching Python installer in passive mode..."); - installer.start(Utils::Misc::windowsSystemPath() + "\\msiexec.exe /passive /i " + Utils::Fs::toNativePath(filePath) + ".msi"); + if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) { + QFile::rename(filePath, filePath + ".exe"); + installer.start("\"" + Utils::Fs::toNativePath(filePath) + ".exe\" /passive"); + } + else { + QFile::rename(filePath, filePath + ".msi"); + installer.start(Utils::Misc::windowsSystemPath() + "\\msiexec.exe /passive /i \"" + Utils::Fs::toNativePath(filePath) + ".msi\""); + } + // Wait for setup to complete - installer.waitForFinished(); + installer.waitForFinished(10 * 60 * 1000); qDebug("Installer stdout: %s", installer.readAllStandardOutput().data()); qDebug("Installer stderr: %s", installer.readAllStandardError().data()); qDebug("Setup should be complete!"); // Delete temp file - Utils::Fs::forceRemove(filePath); + if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) + Utils::Fs::forceRemove(filePath + ".exe"); + else + Utils::Fs::forceRemove(filePath + ".msi"); // Reload search engine m_hasPython = addPythonPathToEnv(); if (m_hasPython) {