Skip to content

Commit

Permalink
Plugin Installer fixes
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9618 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
borysiasty committed Nov 10, 2008
1 parent 6bedde1 commit f5ff6e4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 77 deletions.
Binary file removed python/plugins/plugin_installer/PluginInstaller.png
Binary file not shown.
2 changes: 1 addition & 1 deletion python/plugins/plugin_installer/__init__.py
Expand Up @@ -20,7 +20,7 @@ def author_name():
return "perrygeo, borysiasty"

def version():
return "Version 0.07.2"
return "Version 0.9"

def classFactory(iface):
from installer_plugin import InstallerPlugin
Expand Down
27 changes: 11 additions & 16 deletions python/plugins/plugin_installer/installer_data.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
""" "
"""
Copyright (C) 2007-2008 Matthew Perry
Copyright (C) 2008 Borys Jurgiel
Expand All @@ -11,13 +11,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
This file contains some additional quote marks (for example in the lines 2 and 20), they are
for compatibility with lupdate, which doesn't properly recognize the comments in Python.
The use of lupdate instead of pylupdate is forced by integration with rest of QGIS files,
which are written mainly in C++. After editing this file make sure that lupdate and pylupdate
find the same number of strings and balance the quotemarks if doesn't.
" """
"""


from PyQt4.QtCore import *
Expand All @@ -27,7 +21,7 @@
from unzip import unzip


""" "
"""
Data structure:
mRepositories = dict of dicts: {repoName : {"url" string,
"enabled" bool,
Expand All @@ -50,7 +44,7 @@
"repository" string,
"localdir" string,
"read-only" boolean}}
" """
"""


QGIS_VER = 1
Expand Down Expand Up @@ -487,6 +481,13 @@ def remove(self, key):
# ----------------------------------------- #
def updatePlugin(self, key, readOnly):
""" The mPlugins should contain available plugins first. Now, add installed one (add when not present, update if present) """
if readOnly:
path = QgsApplication.pkgDataPath()
else:
path = QgsApplication.qgisSettingsDirPath()
path = QDir.cleanPath(unicode(path) + "python/plugins/" + key)
if not QDir(path).exists():
return
try:
exec("import "+ key)
try:
Expand Down Expand Up @@ -517,11 +518,6 @@ def updatePlugin(self, key, readOnly):
desc = ""
auth = ""
homepage = ""
if readOnly:
path = QgsApplication.pkgDataPath()
else:
path = QgsApplication.qgisSettingsDirPath()
path = QDir.cleanPath(unicode(path) + "python/plugins/" + key)
normVer = self.normalizeVersion(QString(ver))
plugin = {
"name" : nam,
Expand Down Expand Up @@ -575,7 +571,6 @@ def updatePlugin(self, key, readOnly):
# ----------------------------------------- #
def getAllInstalled(self):
""" update the mPlugins dict with alredy installed plugins """
# ' PLEASE DO NOT REMOVE THIS QUOTE MARK - it is a balance for compatibility with lupdate
# first, try to add the read-only plugins...
try:
pluginDir = QDir.cleanPath(unicode(QgsApplication.pkgDataPath()) + "/python/plugins")
Expand Down
79 changes: 28 additions & 51 deletions python/plugins/plugin_installer/installer_gui.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
""" "
"""
Copyright (C) 2007-2008 Matthew Perry
Copyright (C) 2008 Borys Jurgiel
Expand All @@ -11,13 +11,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
This file contains some additional quote marks (for example in the lines 2 and 20), they are
for compatibility with lupdate, which doesn't properly recognize the comments in Python.
The use of lupdate instead of pylupdate is forced by integration with rest of QGIS files,
which are written mainly in C++. After editing this file make sure that lupdate and pylupdate
find the same number of strings and balance the quotemarks if doesn't.
" """
"""


from PyQt4.QtCore import *
Expand All @@ -37,7 +31,7 @@
def removeDir(path):
result = QString()
if not QFile(path).exists():
result = QCoreApplication.translate("QgsPluginInstaller","Plugin directory doesn't exist: ") + path
result = QCoreApplication.translate("QgsPluginInstaller","Plugin directory doesn't exist:")+"\n"+path
elif QFile(path).remove(): # if it is only link, just remove it without resolving.
#print " Link removing successfull: %s" % path
pass
Expand All @@ -57,7 +51,7 @@ def removeDir(path):
#print " Directory removing successfull: %s" % item
pass
if QFile(path).exists():
result = QCoreApplication.translate("QgsPluginInstaller","Failed to remove directory")+" "+path+" \n"+QCoreApplication.translate("QgsPluginInstaller","Check permissions or remove it manually")
result = QCoreApplication.translate("QgsPluginInstaller","Failed to remove the directory:")+" "+path+"\n"+QCoreApplication.translate("QgsPluginInstaller","Check permissions or remove it manually")
# restore plugin directory if removed by QDir().rmpath()
pluginDir = unicode(QFileInfo(QgsApplication.qgisUserDbFilePath()).path()+"/python/plugins")
if not QDir(pluginDir).exists():
Expand All @@ -70,9 +64,6 @@ def removeDir(path):


# --- class QgsPluginInstallerFetchingDialog --------------------------------------------------------------- #
""" " C++ style header for compability with lupdate
QgsPluginInstallerFetchingDialog::foo(){
" """
class QgsPluginInstallerFetchingDialog(QDialog, Ui_QgsPluginInstallerFetchingDialog):
# ----------------------------------------- #
def __init__(self, parent):
Expand Down Expand Up @@ -118,17 +109,13 @@ def repositoryFetched(self, repoName):
self.displayState(repoName,7)
if not repositories.fetchingInProgress():
self.close()
# } - C++ style footer for compability with lupdate
# --- /class QgsPluginInstallerFetchingDialog -------------------------------------------------------------- #





# --- class QgsPluginInstallerRepositoryDialog ------------------------------------------------------------- #
""" " C++ style header for compability with lupdate
QgsPluginInstallerRepositoryDialog::foo(){
" """
class QgsPluginInstallerRepositoryDialog(QDialog, Ui_QgsPluginInstallerRepositoryDetailsDialog):
# ----------------------------------------- #
def __init__(self, parent=None):
Expand All @@ -143,17 +130,13 @@ def __init__(self, parent=None):
def textChanged(self, string):
enable = (self.editName.text().count() > 0 and self.editURL.text().count() > 0)
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
# } - C++ style footer for compability with lupdate
# --- /class QgsPluginInstallerRepositoryDialog ------------------------------------------------------------ #





# --- class QgsPluginInstallerInstallingDialog --------------------------------------------------------------- #
""" " C++ style header for compability with lupdate
QgsPluginInstallerInstallingDialog::foo(){
" """
class QgsPluginInstallerInstallingDialog(QDialog, Ui_QgsPluginInstallerInstallingDialog):
# ----------------------------------------- #
def __init__(self, parent, plugin):
Expand Down Expand Up @@ -226,7 +209,7 @@ def requestFinished(self, requestId, state):
removeDir(QDir.cleanPath(pluginDir+"/"+self.plugin["localdir"])) # remove old plugin if exists
un.extract(tmpPath, pluginDir) # final extract.
except:
self.mResult = self.tr("Failed to unzip file to ") + pluginDir + "\n" + self.tr("check permissions")
self.mResult = self.tr("Failed to unzip file to the following directory:") + "\n" + pluginDir + "\n" + self.tr("Check permissions")
self.reject()
return

Expand All @@ -244,26 +227,21 @@ def abort(self):
self.http.abort()
self.mResult = self.tr("Aborted by user")
self.reject()
# } - C++ style footer for compability with lupdate
# --- /class QgsPluginInstallerPluginErrorDialog ------------------------------------------------------------- #





# --- class QgsPluginInstallerPluginErrorDialog -------------------------------------------------------------- #
""" " C++ style header for compability with lupdate
QgsPluginInstallerPluginErrorDialog::foo(){
" """
class QgsPluginInstallerPluginErrorDialog(QDialog, Ui_QgsPluginInstallerPluginErrorDialog):
# ----------------------------------------- #
def __init__(self, parent, errorMessage):
QDialog.__init__(self, parent)
self.setupUi(self)
if not errorMessage:
errorMessage = self.tr("No error message received. Try to restart QGIS and ensure the plugin isn't installed under a different name. If it is, contact the plugin author and submit this issue, please.")
errorMessage = self.tr("No error message received. Try to restart Quantum GIS and ensure the plugin isn't installed under a different name. If it is, contact the plugin author and submit this issue, please.")
self.textBrowser.setText(errorMessage)
# } - C++ style footer for compability with lupdate
# --- /class QgsPluginInstallerPluginErrorDialog ------------------------------------------------------------- #


Expand All @@ -272,9 +250,6 @@ def __init__(self, parent, errorMessage):


# --- class QgsPluginInstallerDialog ------------------------------------------------------------------------- #
""" " C++ style header for compability with lupdate
QgsPluginInstallerDialog::foo(){
" """
class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog):
# ----------------------------------------- #
def __init__(self, parent, fl):
Expand Down Expand Up @@ -326,7 +301,7 @@ def getAllAvailablePlugins(self):
# display error messages for every unavailable reposioty, except the case if all repositories are unavailable!
if repositories.allUnavailable() and repositories.allUnavailable() != repositories.allEnabled():
for key in repositories.allUnavailable():
QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), self.tr("Error reading repository: ") + key + "\n" + repositories.all()[key]["error"])
QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), self.tr("Error reading repository:") + " " + key + "\n" + repositories.all()[key]["error"])

plugins.getAllInstalled()

Expand Down Expand Up @@ -357,7 +332,7 @@ def populateMostWidgets(self):
if repositories.all()[key]["valid"]:
a.setToolTip(0,self.tr("This repository is disabled"))
else:
a.setToolTip(0,self.tr("This repository is blocked due to incompatibility with your QGIS version"))
a.setToolTip(0,self.tr("This repository is blocked due to incompatibility with your Quantum GIS version"))
a.setDisabled(True)
for i in [0,1,2]:
self.treeRepositories.resizeColumnToContents(i)
Expand Down Expand Up @@ -425,7 +400,7 @@ def addItem(p):
if self.filterCheck(p):
statusTip = descrip[p["status"]]
if p["read-only"]:
statusTip += "\n" + self.tr("Note that it's a core plugin and I can't uninstall it")
statusTip += "\n" + self.tr("Note that it's an uninsatallable core plugin")
if p["status"] == "upgradeable":
ver = p["version_inst"] + " -> " + p["version_avail"]
elif p["status"] == "newer":
Expand All @@ -435,32 +410,35 @@ def addItem(p):
else:
ver = p["version_inst"]
if p["status"] in ["upgradeable","newer"]:
vd = self.tr("installed version") + ": " + p["version_inst"] + "\n" + self.tr("available version") + ": " + p["version_avail"]
verTip = self.tr("installed version") + ": " + p["version_inst"] + "\n" + self.tr("available version") + ": " + p["version_avail"]
elif p["status"] in ["not installed", "new"]:
vd = self.tr("available version") + ": " + p["version_avail"]
verTip = self.tr("available version") + ": " + p["version_avail"]
elif p["status"] == "installed":
vd = self.tr("installed version") + ": " + p["version_inst"] + "\n" + self.tr("That's the newest available version")
verTip = self.tr("installed version") + ": " + p["version_inst"] + "\n" + self.tr("That's the newest available version")
elif p["status"] == "orphan":
vd = self.tr("installed version") + ": " + p["version_inst"] + "\n" + self.tr("There is no version available for download")
verTip = self.tr("installed version") + ": " + p["version_inst"] + "\n" + self.tr("There is no version available for download")
else:
vd = ""
verTip = ""
if p["status"] == "invalid":
p["desc_local"] = self.tr("This plugin seems to be invalid or have unfulfilled dependencies")
p["desc_repo"] = self.tr("This plugin seems to be invalid or have unfulfilled dependencies\nIt has been installed, but can't be loaded")
desc = self.tr("This plugin seems to be invalid or have unfulfilled dependencies")
descTip = self.tr("This plugin seems to be invalid or have unfulfilled dependencies\nIt has been installed, but can't be loaded")
else:
desc = p["desc_local"]
descTip = p["desc_repo"]
if not desc:
desc = descTip
if not p["repository"]:
repository = self.tr("only locally available")
else:
repository = p["repository"]
if not p["desc_local"]:
p["desc_local"] = p["desc_repo"]
a = QTreeWidgetItem(self.treePlugins)
a.setText(0,status[p["status"]])
a.setToolTip(0,statusTip)
a.setText(1,p["name"])
a.setText(2,ver)
a.setToolTip(2,vd)
a.setText(3,p["desc_local"])
a.setToolTip(3, p["desc_repo"])
a.setToolTip(2,verTip)
a.setText(3,desc)
a.setToolTip(3,descTip)
a.setText(4,p["author"])
if p["homepage"]:
a.setToolTip(4,p["homepage"])
Expand Down Expand Up @@ -578,7 +556,7 @@ def uninstallPlugin(self):
plugin = plugins.all()[key]
if not plugin:
return
warning = self.tr("Are you sure you want to uninstall the plugin ") + plugin["name"] + "?"
warning = self.tr("Are you sure you want to uninstall the following plugin?") + "\n" + plugin["name"]
if plugin["status"] == "orphan":
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:
Expand Down Expand Up @@ -617,7 +595,7 @@ def ChangeCheckingPolicy(self,policy):
def addKnownRepositories(self):
""" update list of known repositories - in the future it will be replaced with an online fetching """
#print "add known repositories"
message = self.tr("You are going to add some plugin repositories neither authorized nor supported by the QGIS team, however provided by folks associated with us. Plugin authors generally make efforts to make their works useful and safe, but we can't assume any responsibility for them. FEEL WARNED!")
message = self.tr("You are going to add some plugin repositories neither authorized nor supported by the Quantum GIS team, however provided by folks associated with us. Plugin authors generally make efforts to make their works useful and safe, but we can't assume any responsibility for them. FEEL WARNED!")
if QMessageBox.question(self, self.tr("QGIS Python Plugin Installer"), message, QMessageBox.Ok, QMessageBox.Abort) == QMessageBox.Ok:
repositories.addKnownRepos()
# refresh lists and populate widgets
Expand Down Expand Up @@ -677,7 +655,7 @@ def editRepository(self):
dlg.labelInfo.setText("")
else:
dlg.checkBoxEnabled.setEnabled(False)
dlg.labelInfo.setText(self.tr("This repository is blocked due to incompatibility with your QGIS version"))
dlg.labelInfo.setText(self.tr("This repository is blocked due to incompatibility with your Quantum GIS version"))
dlg.labelInfo.setFrameShape(QFrame.Box)
if not dlg.exec_():
return # nothing to do if cancelled
Expand Down Expand Up @@ -713,7 +691,7 @@ def deleteRepository(self):
current = self.treeRepositories.currentItem()
if current == None:
return
warning = self.tr("Are you sure you want to remove the repository") + "\n" + current.text(1) + "?"
warning = self.tr("Are you sure you want to remove the following repository?") + "\n" + current.text(1)
if QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), warning , QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
return
reposName = current.text(1)
Expand All @@ -734,5 +712,4 @@ def reject(self):
""" update the list of seen plugins before exit (both 'done' and 'x' buttons emit 'reject' signal) """
plugins.updateSeenPluginsList()
QDialog.reject(self)
# } - C++ style footer for compability with lupdate
# --- /class QgsPluginInstallerDialog ------------------------------------------------------------------------ #
12 changes: 3 additions & 9 deletions python/plugins/plugin_installer/installer_plugin.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
""" "
"""
Copyright (C) 2007-2008 Matthew Perry
Copyright (C) 2008 Borys Jurgiel
Expand All @@ -11,13 +11,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
This file contains some additional quote marks (for example in the lines 2 and 20), they are
for compatibility with lupdate, which doesn't properly recognize the comments in Python.
The use of lupdate instead of pylupdate is forced by integration with rest of QGIS files,
which are written mainly in C++. After editing this file make sure that lupdate and pylupdate
find the same number of strings and balance the quotemarks if doesn't.
" """
"""


from PyQt4.QtCore import *
Expand All @@ -28,7 +22,7 @@
import resources_rc


class InstallerPlugin:
class InstallerPlugin():
# ----------------------------------------- #
def __init__(self, iface):
self.iface = iface
Expand Down

0 comments on commit f5ff6e4

Please sign in to comment.