Skip to content

Commit 2c0daea

Browse files
author
mhugent
committed
Revert accidental change in plugin installer during merge of vector_overlay branch
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10491 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2ef10d0 commit 2c0daea

File tree

1 file changed

+50
-34
lines changed

1 file changed

+50
-34
lines changed

python/plugins/plugin_installer/installer_gui.py

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,6 @@ def installPlugin(self):
571571
if plugin["status"] == "newer" and not plugin["error"]: # ask for confirmation if user downgrades an usable plugin
572572
if QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), self.tr("Are you sure you want to downgrade the plugin to the latest available version? The installed one is newer!"), QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
573573
return
574-
if plugin["status"] == "newer":
575-
if QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), self.tr("Are you sure you want to downgrade the plugin to the latest available version? The installed one is newer!"), QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
576-
return
577-
578574
dlg = QgsPluginInstallerInstallingDialog(self,plugin)
579575
dlg.exec_()
580576

@@ -586,38 +582,58 @@ def installPlugin(self):
586582
self.getAllAvailablePlugins()
587583
QApplication.restoreOverrideCursor()
588584
else:
589-
590-
path = QDir.cleanPath(QgsApplication.qgisSettingsDirPath() + "/python/plugins/" + key)
591-
if not QDir(path).exists():
592-
infoString = (self.tr("Plugin has disappeared"), self.tr("The plugin seems to have been installed but I don't know where. Probably the plugin package contained a wrong named directory.\nPlease search the list of installed plugins. I'm nearly sure you'll find the plugin there, but I just can't determine which of them it is. It also means that I won't be able to determine if this plugin is installed and inform you about available updates. However the plugin may work. Please contact the plugin author and submit this issue."))
593-
QApplication.setOverrideCursor(Qt.WaitCursor)
594-
self.getAllAvailablePlugins()
595-
QApplication.restoreOverrideCursor()
585+
try:
586+
exec ("sys.path_importer_cache.clear()")
587+
exec ("import %s" % plugin["localdir"])
588+
exec ("reload (%s)" % plugin["localdir"])
589+
except:
590+
pass
591+
plugins.updatePlugin(key, False)
592+
plugin = plugins.all()[key]
593+
if not plugin["error"]:
594+
if previousStatus in ["not installed", "new"]:
595+
infoString = (self.tr("Plugin installed successfully"),
596+
self.tr("Python plugin installed.\nNow you need to enable it in Plugin Manager."))
597+
else:
598+
infoString = (self.tr("Plugin reinstalled successfully"),
599+
self.tr("Python plugin reinstalled.\nYou need to restart Quantum GIS in order to reload it."))
596600
else:
597-
try:
598-
exec ("sys.path_importer_cache.clear()")
599-
exec ("del sys.modules[%s]" % plugin["localdir"]) # remove old version if exist
600-
except:
601-
pass
602-
try:
603-
exec ("import %s" % plugin["localdir"])
604-
exec ("reload (%s)" % plugin["localdir"])
605-
if plugin["status"] == "not installed" or plugin["status"] == "new":
606-
infoString = (self.tr("Plugin installed successfully"), self.tr("Python plugin installed.\nYou have to enable it in the Plugin Manager."))
601+
if plugin["error"] == "incompatible":
602+
message = self.tr("The plugin is designed for a newer version of Quantum GIS. The minimum required version is:")
603+
message += " <b>" + plugin["error_details"] + "</b>"
604+
elif plugin["error"] == "dependent":
605+
message = self.tr("The plugin depends on some components missing on your system. You need to install the following Python module in order to enable it:")
606+
message += "<b> " + plugin["error_details"] + "</b>"
607+
else:
608+
message = self.tr("The plugin is broken. Python said:")
609+
message += "<br><b>" + plugin["error_details"] + "</b>"
610+
dlg = QgsPluginInstallerPluginErrorDialog(self,message)
611+
dlg.exec_()
612+
if dlg.result():
613+
# revert installation
614+
plugins.setPluginData(key, "status", "not installed")
615+
plugins.setPluginData(key, "version_inst", "")
616+
plugins.setPluginData(key, "desc_local", "")
617+
plugins.setPluginData(key, "error", "")
618+
plugins.setPluginData(key, "error_details", "")
619+
pluginDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/" + plugin["localdir"]
620+
removeDir(pluginDir)
621+
if QDir(pluginDir).exists():
622+
infoString = (self.tr("Plugin uninstall failed"), result)
623+
try:
624+
exec ("sys.path_importer_cache.clear()")
625+
exec ("import %s" % plugin["localdir"])
626+
exec ("reload (%s)" % plugin["localdir"])
627+
except:
628+
pass
629+
plugins.updatePlugin(key, False)
607630
else:
608-
infoString = (self.tr("Plugin installed successfully"),self.tr("Python plugin reinstalled.\nYou have to restart Quantum GIS to reload it."))
609-
except Exception, error:
610-
dlg = QgsPluginInstallerPluginErrorDialog(self,error.message)
611-
dlg.exec_()
612-
if dlg.result():
613-
pluginDir = unicode(QFileInfo(QgsApplication.qgisUserDbFilePath()).path()+"/python/plugins/"+ str(plugin["localdir"]))
614-
result = removeDir(pluginDir)
615-
if result:
616-
QMessageBox.warning(self, self.tr("Plugin uninstall failed"), result)
617-
plugins.updatePlugin(key, False)
618-
self.populatePluginTree()
619-
return
620-
plugins.updatePlugin(key, False)
631+
try:
632+
exec ("del sys.modules[%s]" % plugin["localdir"])
633+
except:
634+
pass
635+
if not plugin["repository"]:
636+
plugins.remove(key)
621637
self.populatePluginTree()
622638
if infoString[0]:
623639
QMessageBox.information(self, infoString[0], infoString[1])

0 commit comments

Comments
 (0)