Revert accidental change in plugin installer during merge of vector_overlay branch

git-svn-id: http://svn.osgeo.org/qgis/trunk@10491 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2009-04-07 07:11:43 +00:00
parent 39b28ed518
commit 0af72a7a87

View File

@ -571,10 +571,6 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialogBase):
if plugin["status"] == "newer" and not plugin["error"]: # ask for confirmation if user downgrades an usable plugin if plugin["status"] == "newer" and not plugin["error"]: # ask for confirmation if user downgrades an usable plugin
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: 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:
return return
if plugin["status"] == "newer":
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:
return
dlg = QgsPluginInstallerInstallingDialog(self,plugin) dlg = QgsPluginInstallerInstallingDialog(self,plugin)
dlg.exec_() dlg.exec_()
@ -586,38 +582,58 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialogBase):
self.getAllAvailablePlugins() self.getAllAvailablePlugins()
QApplication.restoreOverrideCursor() QApplication.restoreOverrideCursor()
else: else:
try:
path = QDir.cleanPath(QgsApplication.qgisSettingsDirPath() + "/python/plugins/" + key) exec ("sys.path_importer_cache.clear()")
if not QDir(path).exists(): exec ("import %s" % plugin["localdir"])
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.")) exec ("reload (%s)" % plugin["localdir"])
QApplication.setOverrideCursor(Qt.WaitCursor) except:
self.getAllAvailablePlugins() pass
QApplication.restoreOverrideCursor() plugins.updatePlugin(key, False)
plugin = plugins.all()[key]
if not plugin["error"]:
if previousStatus in ["not installed", "new"]:
infoString = (self.tr("Plugin installed successfully"),
self.tr("Python plugin installed.\nNow you need to enable it in Plugin Manager."))
else:
infoString = (self.tr("Plugin reinstalled successfully"),
self.tr("Python plugin reinstalled.\nYou need to restart Quantum GIS in order to reload it."))
else: else:
try: if plugin["error"] == "incompatible":
exec ("sys.path_importer_cache.clear()") message = self.tr("The plugin is designed for a newer version of Quantum GIS. The minimum required version is:")
exec ("del sys.modules[%s]" % plugin["localdir"]) # remove old version if exist message += " <b>" + plugin["error_details"] + "</b>"
except: elif plugin["error"] == "dependent":
pass 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:")
try: message += "<b> " + plugin["error_details"] + "</b>"
exec ("import %s" % plugin["localdir"]) else:
exec ("reload (%s)" % plugin["localdir"]) message = self.tr("The plugin is broken. Python said:")
if plugin["status"] == "not installed" or plugin["status"] == "new": message += "<br><b>" + plugin["error_details"] + "</b>"
infoString = (self.tr("Plugin installed successfully"), self.tr("Python plugin installed.\nYou have to enable it in the Plugin Manager.")) dlg = QgsPluginInstallerPluginErrorDialog(self,message)
dlg.exec_()
if dlg.result():
# revert installation
plugins.setPluginData(key, "status", "not installed")
plugins.setPluginData(key, "version_inst", "")
plugins.setPluginData(key, "desc_local", "")
plugins.setPluginData(key, "error", "")
plugins.setPluginData(key, "error_details", "")
pluginDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/" + plugin["localdir"]
removeDir(pluginDir)
if QDir(pluginDir).exists():
infoString = (self.tr("Plugin uninstall failed"), result)
try:
exec ("sys.path_importer_cache.clear()")
exec ("import %s" % plugin["localdir"])
exec ("reload (%s)" % plugin["localdir"])
except:
pass
plugins.updatePlugin(key, False)
else: else:
infoString = (self.tr("Plugin installed successfully"),self.tr("Python plugin reinstalled.\nYou have to restart Quantum GIS to reload it.")) try:
except Exception, error: exec ("del sys.modules[%s]" % plugin["localdir"])
dlg = QgsPluginInstallerPluginErrorDialog(self,error.message) except:
dlg.exec_() pass
if dlg.result(): if not plugin["repository"]:
pluginDir = unicode(QFileInfo(QgsApplication.qgisUserDbFilePath()).path()+"/python/plugins/"+ str(plugin["localdir"])) plugins.remove(key)
result = removeDir(pluginDir)
if result:
QMessageBox.warning(self, self.tr("Plugin uninstall failed"), result)
plugins.updatePlugin(key, False)
self.populatePluginTree()
return
plugins.updatePlugin(key, False)
self.populatePluginTree() self.populatePluginTree()
if infoString[0]: if infoString[0]:
QMessageBox.information(self, infoString[0], infoString[1]) QMessageBox.information(self, infoString[0], infoString[1])