Skip to content

Commit

Permalink
Plugin installer update
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@14471 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
borysiasty committed Oct 31, 2010
1 parent a7014ed commit bd65124
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 78 deletions.
4 changes: 2 additions & 2 deletions python/plugins/plugin_installer/__init__.py
Expand Up @@ -15,13 +15,13 @@ def name():
return "Plugin Installer"

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

def description():
return "Downloads and installs QGIS python plugins"

def qgisMinimumVersion():
return "0.9"
return "1.0"

def authorName():
return "Matthew Perry, Borys Jurgiel"
Expand Down
76 changes: 25 additions & 51 deletions python/plugins/plugin_installer/installer_data.py
Expand Up @@ -51,19 +51,9 @@
"""


try:
QGIS_VER = QGis.qgisVersion
if QGIS_VER[0] == "1":
QGIS_MAJOR_VER = 1
else:
QGIS_MAJOR_VER = 0
QGIS_14 = False
QGIS_15 = False
except:
QGIS_VER = QGis.QGIS_VERSION
QGIS_MAJOR_VER = 1
QGIS_14 = (QGIS_VER[2] > "3")
QGIS_15 = (QGIS_VER[2] > "4")
QGIS_VER = QGis.QGIS_VERSION
QGIS_14 = (QGIS_VER[2] > "3")
QGIS_15 = (QGIS_VER[2] > "4")



Expand All @@ -79,20 +69,20 @@ def setIface(qgisIface):


# Repositories: (name, url, possible depreciated url)
oldRepo = ("QGIS 0.x Plugin Repository", "http://spatialserver.net/cgi-bin/pyqgis_plugin.rb","")
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"),
# 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", ""),
authorRepos = [("Aaron Racicot's Repository", "http://qgisplugins.z-pulley.com", ""),
("Barry Rowlingson's Repository", "http://www.maths.lancs.ac.uk/~rowlings/Qgis/Plugins/plugins.xml", ""),
("Volkan Kepoglu's Repository","http://ggit.metu.edu.tr/~volkan/plugins.xml", ""),
# depreciated: ("Bob Bruce's Repository", "http://www.mappinggeek.ca/QGISPythonPlugins/Bobs-QGIS-plugins.xml", ""),
# depreciated: ("Borys Jurgiel's Repository", "http://bwj.aster.net.pl/qgis/plugins.xml", "http://bwj.aster.net.pl/qgis-oldapi/plugins.xml"),
("Carson Farmer's Repository", "http://www.ftools.ca/cfarmerQgisRepo.xml", "http://www.ftools.ca/cfarmerQgisRepo_0.xx.xml"),
("CatAIS Repository", "http://www.catais.org/qgis/plugins.xml", ""),
("Faunalia Repository", "http://www.faunalia.it/qgis/plugins.xml", "http://faunalia.it/qgis/plugins.xml"),
("GIS-Lab Repository", "http://gis-lab.info/programs/qgis/qgis-repo.xml", ""),
("Martin Dobias' Sandbox", "http://mapserver.sk/~wonder/qgis/plugins-sandbox.xml", ""),
("Marco Hugentobler's Repository","http://karlinapp.ethz.ch/python_plugins/python_plugins.xml", ""),
("Bob Bruce's Repository", "http://www.mappinggeek.ca/QGISPythonPlugins/Bobs-QGIS-plugins.xml", ""),
("Sourcepole Repository", "http://build.sourcepole.ch/qgis/plugins.xml", "")]
("Sourcepole Repository", "http://build.sourcepole.ch/qgis/plugins.xml", ""),
("Volkan Kepoglu's Repository","http://ggit.metu.edu.tr/~volkan/plugins.xml", "")]



Expand Down Expand Up @@ -205,17 +195,12 @@ def addKnownRepos(self):
settings = QSettings()
settings.beginGroup(reposGroup)
# add the central repositories
if QGIS_MAJOR_VER: # QGIS 1.x
if presentURLs.count(officialRepo[1]) == 0:
settings.setValue(officialRepo[0]+"/url", QVariant(officialRepo[1]))
settings.setValue(officialRepo[0]+"/enabled", QVariant(True))
if presentURLs.count(contribRepo[1]) == 0:
settings.setValue(contribRepo[0]+"/url", QVariant(contribRepo[1]))
settings.setValue(contribRepo[0]+"/enabled", QVariant(True))
else: # QGIS 0.x
if presentURLs.count(oldRepo[1]) == 0:
settings.setValue(oldRepo[0]+"/url", QVariant(oldRepo[1]))
settings.setValue(oldRepo[0]+"/enabled", QVariant(True))
if presentURLs.count(officialRepo[1]) == 0:
settings.setValue(officialRepo[0]+"/url", QVariant(officialRepo[1]))
settings.setValue(officialRepo[0]+"/enabled", QVariant(True))
if presentURLs.count(contribRepo[1]) == 0:
settings.setValue(contribRepo[0]+"/url", QVariant(contribRepo[1]))
settings.setValue(contribRepo[0]+"/enabled", QVariant(True))
# add author repositories
for i in authorRepos:
if i[1] and presentURLs.count(i[1]) == 0:
Expand Down Expand Up @@ -336,31 +321,20 @@ def load(self):
settings = QSettings()
settings.beginGroup(reposGroup)
# first, update repositories in QSettings if needed
if QGIS_MAJOR_VER:
mainRepo = officialRepo
invalidRepo = oldRepo
else:
mainRepo = oldRepo
invalidRepo = officialRepo
mainRepoPresent = False
officialRepoPresent = False
for key in settings.childGroups():
url = settings.value(key+"/url", QVariant()).toString()
if url == contribRepo[1]:
if QGIS_MAJOR_VER:
settings.setValue(key+"/valid", QVariant(True)) # unlock the contrib repo in qgis 1.x
else:
settings.setValue(key+"/valid", QVariant(False)) # lock the contrib repo in qgis 0.x
settings.setValue(key+"/valid", QVariant(True)) # unlock the contrib repo in qgis 1.x
else:
settings.setValue(key+"/valid", QVariant(True)) # unlock any other repo
if url == mainRepo[1]:
mainRepoPresent = True
if url == invalidRepo[1]:
settings.remove(key)
if url == officialRepo[1]:
officialRepoPresent = True
for authorRepo in authorRepos:
if url == authorRepo[2]:
settings.setValue(key+"/url", QVariant(authorRepo[1])) # correct a depreciated url
if not mainRepoPresent:
settings.setValue(mainRepo[0]+"/url", QVariant(mainRepo[1]))
if not officialRepoPresent:
settings.setValue(officialRepo[0]+"/url", QVariant(officialRepo[1]))

for key in settings.childGroups():
self.mRepositories[key] = {}
Expand Down Expand Up @@ -458,7 +432,7 @@ def xmlDownloaded(self,nr,state):
#if compatible, add the plugin to the list
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"):
if QGIS_VER[0]==qgisMinimumVersion[0] or (qgisMinimumVersion!="0" and qgisMaximumVersion!="2"): # to be deleted
#add the plugin to the cache
plugins.addFromRepository(plugin)
self.mRepositories[reposName]["state"] = 2
Expand Down
17 changes: 10 additions & 7 deletions python/plugins/plugin_installer/installer_gui.py
Expand Up @@ -290,8 +290,6 @@ def __init__(self, parent, fl):
index = intervals.index(interval)
else:
index = 1
if QGIS_VER[0] == "0":
self.label_2.setText("<b>Note: This functionality requires QGIS 1.0</b>")
self.comboInterval.setCurrentIndex(index)
self.populateMostWidgets()

Expand Down Expand Up @@ -362,7 +360,7 @@ def populateMostWidgets(self):
if plugins.isThereAnythingNew():
self.comboFilter2.addItem(self.tr("upgradeable and news"))
#set configuration widgets (dependent on the repository list)
if len(repositories.all()) == 1 or QGIS_VER[0] == "0":
if len(repositories.all()) == 1:
self.radioPluginType0.setEnabled(False)
self.radioPluginType1.setEnabled(False)
self.radioPluginType2.setEnabled(False)
Expand All @@ -372,9 +370,7 @@ def populateMostWidgets(self):
self.radioPluginType2.setEnabled(True)
settings = QSettings()
(i, ok) = settings.value(settingsGroup+"/allowedPluginType", QVariant(2)).toInt()
if QGIS_VER[0] == "0":
self.radioPluginType1.setChecked(Qt.Checked)
elif i == 1 or len(repositories.all()) == 1:
if i == 1 or len(repositories.all()) == 1:
self.radioPluginType0.setChecked(Qt.Checked)
elif i == 3:
self.radioPluginType2.setChecked(Qt.Checked)
Expand Down Expand Up @@ -617,7 +613,14 @@ def installPlugin(self):
startPlugin(plugin["localdir"])
else: 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."))
if QGIS_15: # plugins can be reloaded on the fly in QGIS >= 1.5
settings = QSettings()
if key != 'plugin_installer' and settings.value("/PythonPlugins/"+key).toBool(): # plugin will be reloaded on the fly only if currently loaded
infoString = (self.tr("Plugin reinstalled successfully"), self.tr("Plugin reinstalled successfully"))
reloadPlugin(key)
else:
infoString = (self.tr("Plugin reinstalled successfully"), self.tr("Python plugin reinstalled.\nYou need to restart Quantum GIS in order to reload it."))
else: infoString = (self.tr("Plugin reinstalled successfully"), self.tr("Python plugin reinstalled.\nYou need to restart Quantum GIS in order to reload it."))
else:
if plugin["error"] == "incompatible":
message = self.tr("The plugin is designed for a newer version of Quantum GIS. The minimum required version is:")
Expand Down
23 changes: 5 additions & 18 deletions python/plugins/plugin_installer/installer_plugin.py
Expand Up @@ -27,10 +27,7 @@ class InstallerPlugin():
def __init__(self, iface):
self.iface = iface
setIface(self.iface) #pass self.iface to installer_data module (needed for plugin loading & testing)
if QGIS_MAJOR_VER: # new plugin API
self.mainWindow = self.iface.mainWindow
else: # old plugin API
self.mainWindow = self.iface.getMainWindow
self.mainWindow = self.iface.mainWindow
self.guiDlg = None


Expand All @@ -43,9 +40,6 @@ def setCurrentTheme(self, theThemeName):
# ----------------------------------------- #
def getThemeIcon(self, theName):
""" get the icon from the best available theme """
if not QGIS_MAJOR_VER: # QGIS 0.x
return QIcon(":/plugins/installer/" + theName)

myCurThemePath = QgsApplication.activeThemePath() + "/plugins/" + theName;
myDefThemePath = QgsApplication.defaultThemePath() + "/plugins/" + theName;
myQrcPath = ":/plugins/installer/" + theName;
Expand All @@ -65,12 +59,8 @@ def initGui(self):
self.action = QAction(self.getThemeIcon("plugin_installer.png"), QCoreApplication.translate("QgsPluginInstaller","Fetch Python Plugins..."), self.mainWindow())
self.action.setWhatsThis(QCoreApplication.translate("QgsPluginInstaller","Install more plugins from remote repositories"))
self.action.setStatusTip(QCoreApplication.translate("QgsPluginInstaller","Install more plugins from remote repositories"))
if QGIS_MAJOR_VER: # new plugin API
nextAction = self.iface.actionManagePlugins()
self.iface.pluginMenu().insertAction(nextAction,self.action)
else: # old plugin API
nextAction = self.mainWindow().menuBar().actions()[4].menu().actions()[1]
self.mainWindow().menuBar().actions()[4].menu().insertAction(nextAction,self.action)
nextAction = self.iface.actionManagePlugins()
self.iface.pluginMenu().insertAction(nextAction,self.action)
QObject.connect(self.action, SIGNAL("triggered()"), self.run)
QObject.connect(self.iface, SIGNAL("currentThemeChanged ( QString )"), self.setCurrentTheme)
self.statusLabel = None
Expand All @@ -90,7 +80,7 @@ def initGui(self):
repositories.setRepositoryData(key,"state",3)

for i in plugins.obsoletePlugins:
QMessageBox.warning(self.mainWindow(), QCoreApplication.translate("QgsPluginInstaller","QGIS Plugin Conflict:")+" "+plugins.localCache[i]["name"], QCoreApplication.translate("QgsPluginInstaller","The Plugin Installer has detected an obsolete plugin which masks a newer version shipped with this QGIS version. This is likely due to files associated with a previous installation of QGIS. Please use the Plugin Installer to remove that older plugin in order to unmask the newer version shipped with this copy of QGIS."))
QMessageBox.warning(self.mainWindow(), QCoreApplication.translate("QgsPluginInstaller","QGIS Plugin Conflict:")+" "+plugins.localCache[i]["name"], "<b>"+ plugins.localCache[i]["name"] + "</b><br/><br/>" + QCoreApplication.translate("QgsPluginInstaller","The Plugin Installer has detected an obsolete plugin which masks a newer version shipped with this QGIS version. This is likely due to files associated with a previous installation of QGIS. Please use the Plugin Installer to remove that older plugin in order to unmask the newer version shipped with this copy of QGIS."))


# ----------------------------------------- #
Expand Down Expand Up @@ -123,10 +113,7 @@ def unload(self):
# kill pending http requests
for key in repositories.all():
repositories.killConnection(key)
if QGIS_MAJOR_VER: # new plugin API
self.iface.pluginMenu().removeAction(self.action)
else: # old plugin API
self.mainWindow().menuBar().actions()[4].menu().removeAction(self.action)
self.iface.pluginMenu().removeAction(self.action)
if self.statusLabel:
self.mainWindow().statusBar().removeWidget(self.statusLabel)
if self.guiDlg:
Expand Down

0 comments on commit bd65124

Please sign in to comment.