mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
support for python plugin directory with accents in username (fixes #2512 again)
This commit is contained in:
parent
b2d582a597
commit
4cb37b1af2
@ -21,6 +21,7 @@ email : lorenxo86@gmail.com
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from qgis.core import *
|
||||
import qgis.utils
|
||||
|
||||
# Initialize Qt resources from file resources_rc.py
|
||||
import resources_rc
|
||||
@ -39,7 +40,7 @@ except ImportError, e:
|
||||
# if the plugin is shipped with QGis catch the exception and
|
||||
# display an error message
|
||||
import os.path
|
||||
qgisUserPluginPath = os.path.abspath( os.path.join( unicode( QgsApplication.qgisSettingsDirPath() ), "python") )
|
||||
qgisUserPluginPath = qgis.utils.home_plugin_path
|
||||
if not os.path.dirname(__file__).startswith( qgisUserPluginPath ):
|
||||
title = QCoreApplication.translate( "GdalTools", "Plugin error" )
|
||||
message = QCoreApplication.translate( "GdalTools", u'Unable to load {0} plugin. \nThe required "{1}" module is missing. \nInstall it and try again.' )
|
||||
@ -68,8 +69,8 @@ class GdalTools:
|
||||
|
||||
if QGis.QGIS_VERSION[0:3] < "1.5":
|
||||
# For i18n support
|
||||
userPluginPath = QFileInfo( QgsApplication.qgisUserDbFilePath() ).path() + "/python/plugins/GdalTools"
|
||||
systemPluginPath = QgsApplication.prefixPath() + "/python/plugins/GdalTools"
|
||||
userPluginPath = qgis.utils.home_plugin_path + "/GdalTools"
|
||||
systemPluginPath = qgis.utils.sys_plugin_path + "/GdalTools"
|
||||
|
||||
overrideLocale = QSettings().value( "locale/overrideFlag", False, type=bool )
|
||||
if not overrideLocale:
|
||||
|
||||
@ -53,7 +53,7 @@ from utilities_test import getQgisTestApp
|
||||
pardir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
sys.path.append(pardir)
|
||||
|
||||
sys.path.append('/usr/share/qgis/python/plugins')
|
||||
sys.path.append( qgis.utils.sys_plugin_path )
|
||||
|
||||
(QGISAPP, CANVAS, IFACE, PARENT) = getQgisTestApp()
|
||||
|
||||
|
||||
@ -287,7 +287,7 @@ class QgsPluginInstaller(QObject):
|
||||
|
||||
if dlg.result():
|
||||
infoString = (self.tr("Plugin installation failed"), dlg.result())
|
||||
elif not QDir(QDir.cleanPath(QgsApplication.qgisSettingsDirPath() + "/python/plugins/" + key)).exists():
|
||||
elif not QDir( qgis.utils.home_plugin_path + "/" + key ).exists():
|
||||
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."))
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
plugins.getAllInstalled()
|
||||
@ -336,7 +336,7 @@ class QgsPluginInstaller(QObject):
|
||||
dlg.exec_()
|
||||
if dlg.result():
|
||||
# revert installation
|
||||
pluginDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/" + plugin["id"]
|
||||
pluginDir = qgis.utils.home_python_pluginpath + "/" + plugin["id"]
|
||||
removeDir(pluginDir)
|
||||
if QDir(pluginDir).exists():
|
||||
infoString = (self.tr("Plugin uninstall failed"), result)
|
||||
@ -380,7 +380,7 @@ class QgsPluginInstaller(QObject):
|
||||
unloadPlugin(key)
|
||||
except:
|
||||
pass
|
||||
pluginDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/" + plugin["id"]
|
||||
pluginDir = qgis.utils.home_python_pluginpath + "/" + plugin["id"]
|
||||
result = removeDir(pluginDir)
|
||||
if result:
|
||||
QMessageBox.warning(iface.mainWindow(), self.tr("Plugin uninstall failed"), result)
|
||||
|
||||
@ -136,7 +136,7 @@ def removeDir(path):
|
||||
if QFile(path).exists():
|
||||
result = QCoreApplication.translate("QgsPluginInstaller","Failed to remove the directory:")+"\n"+path+"\n"+QCoreApplication.translate("QgsPluginInstaller","Check permissions or remove it manually")
|
||||
# restore plugin directory if removed by QDir().rmpath()
|
||||
pluginDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins"
|
||||
pluginDir = qgis.utils.home_plugin_path
|
||||
if not QDir(pluginDir).exists():
|
||||
QDir().mkpath(pluginDir)
|
||||
return result
|
||||
|
||||
@ -96,7 +96,7 @@ class QgsPluginInstallerInstallingDialog(QDialog, Ui_QgsPluginInstallerInstallin
|
||||
self.file.close()
|
||||
self.stateChanged(0)
|
||||
reply.deleteLater()
|
||||
pluginDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins"
|
||||
pluginDir = qgis.utils.home_plugin_path
|
||||
tmpPath = self.file.fileName()
|
||||
# make sure that the parent directory exists
|
||||
if not QDir(pluginDir).exists():
|
||||
|
||||
@ -155,6 +155,8 @@ void QgsPythonUtilsImpl::initPython( QgisInterface* interface )
|
||||
|
||||
// tell the utils script where to look for the plugins
|
||||
runString( "qgis.utils.plugin_paths = [" + pluginpaths.join( "," ) + "]" );
|
||||
runString( "qgis.utils.sys_plugin_path = \"" + pluginsPath() + "\"" );
|
||||
runString( "qgis.utils.home_plugin_path = " + homePluginsPath() );
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
runString( "if oldhome: os.environ['HOME']=oldhome\n" );
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user