Skip to content

Commit

Permalink
Plugin installer fixes: fix error when uninstalling installer itself,…
Browse files Browse the repository at this point in the history
… support for <disabled> repo tag, remove my repository

git-svn-id: http://svn.osgeo.org/qgis/trunk@13830 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
borysiasty committed Jun 28, 2010
1 parent b98a7ba commit e6507ad
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
4 changes: 2 additions & 2 deletions python/plugins/plugin_installer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2007-2008 Matthew Perry
Copyright (C) 2008-2009 Borys Jurgiel
Copyright (C) 2008-2010 Borys Jurgiel
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
Expand All @@ -15,7 +15,7 @@ def name():
return "Plugin Installer"

def version():
return "Version 1.0.11"
return "Version 1.0.12"

def description():
return "Downloads and installs QGIS python plugins"
Expand Down
7 changes: 4 additions & 3 deletions python/plugins/plugin_installer/installer_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2007-2008 Matthew Perry
Copyright (C) 2008-2009 Borys Jurgiel
Copyright (C) 2008-2010 Borys Jurgiel
/***************************************************************************
* *
Expand Down Expand Up @@ -83,7 +83,7 @@ def setIface(qgisIface):
officialRepo = ("QGIS Official Repository", "http://pyqgis.org/repo/official","")
contribRepo = ("QGIS Contributed Repository", "http://pyqgis.org/repo/contributed","")
authorRepos = [("Carson Farmer's Repository", "http://www.ftools.ca/cfarmerQgisRepo.xml", "http://www.ftools.ca/cfarmerQgisRepo_0.xx.xml"),
("Borys Jurgiel's Repository", "http://bwj.aster.net.pl/qgis/plugins.xml", "http://bwj.aster.net.pl/qgis-oldapi/plugins.xml"),
# depreciated: ("Borys Jurgiel's Repository", "http://bwj.aster.net.pl/qgis/plugins.xml", "http://bwj.aster.net.pl/qgis-oldapi/plugins.xml"),
("Faunalia Repository", "http://www.faunalia.it/qgis/plugins.xml", "http://faunalia.it/qgis/plugins.xml"),
("Martin Dobias' Sandbox", "http://mapserver.sk/~wonder/qgis/plugins-sandbox.xml", ""),
("Aaron Racicot's Repository", "http://qgisplugins.z-pulley.com", ""),
Expand Down Expand Up @@ -456,7 +456,8 @@ def xmlDownloaded(self,nr,state):
qgisMaximumVersion = pluginNodes.item(i).firstChildElement("qgis_maximum_version").text().simplified()
if not qgisMaximumVersion: qgisMaximumVersion = "2"
#if compatible, add the plugin to the list
if compareVersions(QGIS_VER, qgisMinimumVersion) < 2 and compareVersions(qgisMaximumVersion, QGIS_VER) < 2:
if not pluginNodes.item(i).firstChildElement("disabled").text().simplified().toUpper() in ["TRUE","YES"]:
if compareVersions(QGIS_VER, qgisMinimumVersion) < 2 and compareVersions(qgisMaximumVersion, QGIS_VER) < 2:
if QGIS_VER[0]==qgisMinimumVersion[0] or name=="plugin_installer" or (qgisMinimumVersion!="0" and qgisMaximumVersion!="2"):
#add the plugin to the cache
plugins.addFromRepository(plugin)
Expand Down
17 changes: 15 additions & 2 deletions python/plugins/plugin_installer/installer_gui.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2007-2008 Matthew Perry
Copyright (C) 2008-2009 Borys Jurgiel
Copyright (C) 2008-2010 Borys Jurgiel
/***************************************************************************
* *
Expand All @@ -27,7 +27,7 @@

try:
from qgis.utils import startPlugin, unloadPlugin, loadPlugin # QGIS >= 1.4
from qgis.utils import updateAvailablePlugins # QGIS >= 1.5
from qgis.utils import reloadPlugin, updateAvailablePlugins # QGIS >= 1.5
except Exception:
pass

Expand Down Expand Up @@ -676,11 +676,24 @@ def uninstallPlugin(self):
warning += "\n\n"+self.tr("Warning: this plugin isn't available in any accessible repository!")
if QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), warning , QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
return
# unload the plugin if it's not plugin_installer itself (otherwise, do it after removing its directory):
if key != "plugin_installer":
try:
unloadPlugin(key)
except:
pass
pluginDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/" + plugin["localdir"]
result = removeDir(pluginDir)
if result:
QMessageBox.warning(self, self.tr("Plugin uninstall failed"), result)
else:
# if the uninstalled plugin is the installer itself, reload it and quit
if key == "plugin_installer":
try:
reloadPlugin(key)
return
except:
pass
# safe remove
try:
unloadPlugin(plugin["localdir"])
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/plugin_installer/installer_plugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2007-2008 Matthew Perry
Copyright (C) 2008-2009 Borys Jurgiel
Copyright (C) 2008-2010 Borys Jurgiel
/***************************************************************************
* *
Expand Down Expand Up @@ -128,6 +128,7 @@ def unload(self):
self.mainWindow().menuBar().actions()[4].menu().removeAction(self.action)
if self.statusLabel:
self.mainWindow().statusBar().removeWidget(self.statusLabel)
self.guiDlg.close()


# ----------------------------------------- #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<property name="minimumSize">
<size>
<width>480</width>
<height>150</height>
<height>182</height>
</size>
</property>
<property name="windowTitle">
Expand Down

0 comments on commit e6507ad

Please sign in to comment.