Skip to content

Commit f5ff6e4

Browse files
author
borysiasty
committed
Plugin Installer fixes
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9618 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 6bedde1 commit f5ff6e4

File tree

5 files changed

+43
-77
lines changed

5 files changed

+43
-77
lines changed
Binary file not shown.

python/plugins/plugin_installer/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def author_name():
2020
return "perrygeo, borysiasty"
2121

2222
def version():
23-
return "Version 0.07.2"
23+
return "Version 0.9"
2424

2525
def classFactory(iface):
2626
from installer_plugin import InstallerPlugin

python/plugins/plugin_installer/installer_data.py

+11-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
""" "
2+
"""
33
Copyright (C) 2007-2008 Matthew Perry
44
Copyright (C) 2008 Borys Jurgiel
55
@@ -11,13 +11,7 @@
1111
* (at your option) any later version. *
1212
* *
1313
***************************************************************************/
14-
15-
This file contains some additional quote marks (for example in the lines 2 and 20), they are
16-
for compatibility with lupdate, which doesn't properly recognize the comments in Python.
17-
The use of lupdate instead of pylupdate is forced by integration with rest of QGIS files,
18-
which are written mainly in C++. After editing this file make sure that lupdate and pylupdate
19-
find the same number of strings and balance the quotemarks if doesn't.
20-
" """
14+
"""
2115

2216

2317
from PyQt4.QtCore import *
@@ -27,7 +21,7 @@
2721
from unzip import unzip
2822

2923

30-
""" "
24+
"""
3125
Data structure:
3226
mRepositories = dict of dicts: {repoName : {"url" string,
3327
"enabled" bool,
@@ -50,7 +44,7 @@
5044
"repository" string,
5145
"localdir" string,
5246
"read-only" boolean}}
53-
" """
47+
"""
5448

5549

5650
QGIS_VER = 1
@@ -487,6 +481,13 @@ def remove(self, key):
487481
# ----------------------------------------- #
488482
def updatePlugin(self, key, readOnly):
489483
""" The mPlugins should contain available plugins first. Now, add installed one (add when not present, update if present) """
484+
if readOnly:
485+
path = QgsApplication.pkgDataPath()
486+
else:
487+
path = QgsApplication.qgisSettingsDirPath()
488+
path = QDir.cleanPath(unicode(path) + "python/plugins/" + key)
489+
if not QDir(path).exists():
490+
return
490491
try:
491492
exec("import "+ key)
492493
try:
@@ -517,11 +518,6 @@ def updatePlugin(self, key, readOnly):
517518
desc = ""
518519
auth = ""
519520
homepage = ""
520-
if readOnly:
521-
path = QgsApplication.pkgDataPath()
522-
else:
523-
path = QgsApplication.qgisSettingsDirPath()
524-
path = QDir.cleanPath(unicode(path) + "python/plugins/" + key)
525521
normVer = self.normalizeVersion(QString(ver))
526522
plugin = {
527523
"name" : nam,
@@ -575,7 +571,6 @@ def updatePlugin(self, key, readOnly):
575571
# ----------------------------------------- #
576572
def getAllInstalled(self):
577573
""" update the mPlugins dict with alredy installed plugins """
578-
# ' PLEASE DO NOT REMOVE THIS QUOTE MARK - it is a balance for compatibility with lupdate
579574
# first, try to add the read-only plugins...
580575
try:
581576
pluginDir = QDir.cleanPath(unicode(QgsApplication.pkgDataPath()) + "/python/plugins")

python/plugins/plugin_installer/installer_gui.py

+28-51
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
""" "
2+
"""
33
Copyright (C) 2007-2008 Matthew Perry
44
Copyright (C) 2008 Borys Jurgiel
55
@@ -11,13 +11,7 @@
1111
* (at your option) any later version. *
1212
* *
1313
***************************************************************************/
14-
15-
This file contains some additional quote marks (for example in the lines 2 and 20), they are
16-
for compatibility with lupdate, which doesn't properly recognize the comments in Python.
17-
The use of lupdate instead of pylupdate is forced by integration with rest of QGIS files,
18-
which are written mainly in C++. After editing this file make sure that lupdate and pylupdate
19-
find the same number of strings and balance the quotemarks if doesn't.
20-
" """
14+
"""
2115

2216

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

7165

7266
# --- class QgsPluginInstallerFetchingDialog --------------------------------------------------------------- #
73-
""" " C++ style header for compability with lupdate
74-
QgsPluginInstallerFetchingDialog::foo(){
75-
" """
7667
class QgsPluginInstallerFetchingDialog(QDialog, Ui_QgsPluginInstallerFetchingDialog):
7768
# ----------------------------------------- #
7869
def __init__(self, parent):
@@ -118,17 +109,13 @@ def repositoryFetched(self, repoName):
118109
self.displayState(repoName,7)
119110
if not repositories.fetchingInProgress():
120111
self.close()
121-
# } - C++ style footer for compability with lupdate
122112
# --- /class QgsPluginInstallerFetchingDialog -------------------------------------------------------------- #
123113

124114

125115

126116

127117

128118
# --- class QgsPluginInstallerRepositoryDialog ------------------------------------------------------------- #
129-
""" " C++ style header for compability with lupdate
130-
QgsPluginInstallerRepositoryDialog::foo(){
131-
" """
132119
class QgsPluginInstallerRepositoryDialog(QDialog, Ui_QgsPluginInstallerRepositoryDetailsDialog):
133120
# ----------------------------------------- #
134121
def __init__(self, parent=None):
@@ -143,17 +130,13 @@ def __init__(self, parent=None):
143130
def textChanged(self, string):
144131
enable = (self.editName.text().count() > 0 and self.editURL.text().count() > 0)
145132
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
146-
# } - C++ style footer for compability with lupdate
147133
# --- /class QgsPluginInstallerRepositoryDialog ------------------------------------------------------------ #
148134

149135

150136

151137

152138

153139
# --- class QgsPluginInstallerInstallingDialog --------------------------------------------------------------- #
154-
""" " C++ style header for compability with lupdate
155-
QgsPluginInstallerInstallingDialog::foo(){
156-
" """
157140
class QgsPluginInstallerInstallingDialog(QDialog, Ui_QgsPluginInstallerInstallingDialog):
158141
# ----------------------------------------- #
159142
def __init__(self, parent, plugin):
@@ -226,7 +209,7 @@ def requestFinished(self, requestId, state):
226209
removeDir(QDir.cleanPath(pluginDir+"/"+self.plugin["localdir"])) # remove old plugin if exists
227210
un.extract(tmpPath, pluginDir) # final extract.
228211
except:
229-
self.mResult = self.tr("Failed to unzip file to ") + pluginDir + "\n" + self.tr("check permissions")
212+
self.mResult = self.tr("Failed to unzip file to the following directory:") + "\n" + pluginDir + "\n" + self.tr("Check permissions")
230213
self.reject()
231214
return
232215

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

250232

251233

252234

253235

254236
# --- class QgsPluginInstallerPluginErrorDialog -------------------------------------------------------------- #
255-
""" " C++ style header for compability with lupdate
256-
QgsPluginInstallerPluginErrorDialog::foo(){
257-
" """
258237
class QgsPluginInstallerPluginErrorDialog(QDialog, Ui_QgsPluginInstallerPluginErrorDialog):
259238
# ----------------------------------------- #
260239
def __init__(self, parent, errorMessage):
261240
QDialog.__init__(self, parent)
262241
self.setupUi(self)
263242
if not errorMessage:
264-
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.")
243+
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.")
265244
self.textBrowser.setText(errorMessage)
266-
# } - C++ style footer for compability with lupdate
267245
# --- /class QgsPluginInstallerPluginErrorDialog ------------------------------------------------------------- #
268246

269247

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

273251

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

331306
plugins.getAllInstalled()
332307

@@ -357,7 +332,7 @@ def populateMostWidgets(self):
357332
if repositories.all()[key]["valid"]:
358333
a.setToolTip(0,self.tr("This repository is disabled"))
359334
else:
360-
a.setToolTip(0,self.tr("This repository is blocked due to incompatibility with your QGIS version"))
335+
a.setToolTip(0,self.tr("This repository is blocked due to incompatibility with your Quantum GIS version"))
361336
a.setDisabled(True)
362337
for i in [0,1,2]:
363338
self.treeRepositories.resizeColumnToContents(i)
@@ -425,7 +400,7 @@ def addItem(p):
425400
if self.filterCheck(p):
426401
statusTip = descrip[p["status"]]
427402
if p["read-only"]:
428-
statusTip += "\n" + self.tr("Note that it's a core plugin and I can't uninstall it")
403+
statusTip += "\n" + self.tr("Note that it's an uninsatallable core plugin")
429404
if p["status"] == "upgradeable":
430405
ver = p["version_inst"] + " -> " + p["version_avail"]
431406
elif p["status"] == "newer":
@@ -435,32 +410,35 @@ def addItem(p):
435410
else:
436411
ver = p["version_inst"]
437412
if p["status"] in ["upgradeable","newer"]:
438-
vd = self.tr("installed version") + ": " + p["version_inst"] + "\n" + self.tr("available version") + ": " + p["version_avail"]
413+
verTip = self.tr("installed version") + ": " + p["version_inst"] + "\n" + self.tr("available version") + ": " + p["version_avail"]
439414
elif p["status"] in ["not installed", "new"]:
440-
vd = self.tr("available version") + ": " + p["version_avail"]
415+
verTip = self.tr("available version") + ": " + p["version_avail"]
441416
elif p["status"] == "installed":
442-
vd = self.tr("installed version") + ": " + p["version_inst"] + "\n" + self.tr("That's the newest available version")
417+
verTip = self.tr("installed version") + ": " + p["version_inst"] + "\n" + self.tr("That's the newest available version")
443418
elif p["status"] == "orphan":
444-
vd = self.tr("installed version") + ": " + p["version_inst"] + "\n" + self.tr("There is no version available for download")
419+
verTip = self.tr("installed version") + ": " + p["version_inst"] + "\n" + self.tr("There is no version available for download")
445420
else:
446-
vd = ""
421+
verTip = ""
447422
if p["status"] == "invalid":
448-
p["desc_local"] = self.tr("This plugin seems to be invalid or have unfulfilled dependencies")
449-
p["desc_repo"] = self.tr("This plugin seems to be invalid or have unfulfilled dependencies\nIt has been installed, but can't be loaded")
423+
desc = self.tr("This plugin seems to be invalid or have unfulfilled dependencies")
424+
descTip = self.tr("This plugin seems to be invalid or have unfulfilled dependencies\nIt has been installed, but can't be loaded")
425+
else:
426+
desc = p["desc_local"]
427+
descTip = p["desc_repo"]
428+
if not desc:
429+
desc = descTip
450430
if not p["repository"]:
451431
repository = self.tr("only locally available")
452432
else:
453433
repository = p["repository"]
454-
if not p["desc_local"]:
455-
p["desc_local"] = p["desc_repo"]
456434
a = QTreeWidgetItem(self.treePlugins)
457435
a.setText(0,status[p["status"]])
458436
a.setToolTip(0,statusTip)
459437
a.setText(1,p["name"])
460438
a.setText(2,ver)
461-
a.setToolTip(2,vd)
462-
a.setText(3,p["desc_local"])
463-
a.setToolTip(3, p["desc_repo"])
439+
a.setToolTip(2,verTip)
440+
a.setText(3,desc)
441+
a.setToolTip(3,descTip)
464442
a.setText(4,p["author"])
465443
if p["homepage"]:
466444
a.setToolTip(4,p["homepage"])
@@ -578,7 +556,7 @@ def uninstallPlugin(self):
578556
plugin = plugins.all()[key]
579557
if not plugin:
580558
return
581-
warning = self.tr("Are you sure you want to uninstall the plugin ") + plugin["name"] + "?"
559+
warning = self.tr("Are you sure you want to uninstall the following plugin?") + "\n" + plugin["name"]
582560
if plugin["status"] == "orphan":
583561
warning += "\n\n"+self.tr("Warning: this plugin isn't available in any accessible repository!")
584562
if QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), warning , QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
@@ -617,7 +595,7 @@ def ChangeCheckingPolicy(self,policy):
617595
def addKnownRepositories(self):
618596
""" update list of known repositories - in the future it will be replaced with an online fetching """
619597
#print "add known repositories"
620-
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!")
598+
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!")
621599
if QMessageBox.question(self, self.tr("QGIS Python Plugin Installer"), message, QMessageBox.Ok, QMessageBox.Abort) == QMessageBox.Ok:
622600
repositories.addKnownRepos()
623601
# refresh lists and populate widgets
@@ -677,7 +655,7 @@ def editRepository(self):
677655
dlg.labelInfo.setText("")
678656
else:
679657
dlg.checkBoxEnabled.setEnabled(False)
680-
dlg.labelInfo.setText(self.tr("This repository is blocked due to incompatibility with your QGIS version"))
658+
dlg.labelInfo.setText(self.tr("This repository is blocked due to incompatibility with your Quantum GIS version"))
681659
dlg.labelInfo.setFrameShape(QFrame.Box)
682660
if not dlg.exec_():
683661
return # nothing to do if cancelled
@@ -713,7 +691,7 @@ def deleteRepository(self):
713691
current = self.treeRepositories.currentItem()
714692
if current == None:
715693
return
716-
warning = self.tr("Are you sure you want to remove the repository") + "\n" + current.text(1) + "?"
694+
warning = self.tr("Are you sure you want to remove the following repository?") + "\n" + current.text(1)
717695
if QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), warning , QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
718696
return
719697
reposName = current.text(1)
@@ -734,5 +712,4 @@ def reject(self):
734712
""" update the list of seen plugins before exit (both 'done' and 'x' buttons emit 'reject' signal) """
735713
plugins.updateSeenPluginsList()
736714
QDialog.reject(self)
737-
# } - C++ style footer for compability with lupdate
738715
# --- /class QgsPluginInstallerDialog ------------------------------------------------------------------------ #

python/plugins/plugin_installer/installer_plugin.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
""" "
2+
"""
33
Copyright (C) 2007-2008 Matthew Perry
44
Copyright (C) 2008 Borys Jurgiel
55
@@ -11,13 +11,7 @@
1111
* (at your option) any later version. *
1212
* *
1313
***************************************************************************/
14-
15-
This file contains some additional quote marks (for example in the lines 2 and 20), they are
16-
for compatibility with lupdate, which doesn't properly recognize the comments in Python.
17-
The use of lupdate instead of pylupdate is forced by integration with rest of QGIS files,
18-
which are written mainly in C++. After editing this file make sure that lupdate and pylupdate
19-
find the same number of strings and balance the quotemarks if doesn't.
20-
" """
14+
"""
2115

2216

2317
from PyQt4.QtCore import *
@@ -28,7 +22,7 @@
2822
import resources_rc
2923

3024

31-
class InstallerPlugin:
25+
class InstallerPlugin():
3226
# ----------------------------------------- #
3327
def __init__(self, iface):
3428
self.iface = iface

0 commit comments

Comments
 (0)