Skip to content

Commit

Permalink
support for python plugin directory with accents in username (fixes #…
Browse files Browse the repository at this point in the history
…2512 again)
  • Loading branch information
jef-n committed Oct 10, 2013
1 parent b2d582a commit 4cb37b1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions python/plugins/GdalTools/GdalTools.py
Expand Up @@ -21,6 +21,7 @@
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
Expand All @@ -39,7 +40,7 @@
# 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.' )
Expand Down Expand Up @@ -68,8 +69,8 @@ def __init__( self, iface ):

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:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/tests/test.py
Expand Up @@ -53,7 +53,7 @@
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()

Expand Down
6 changes: 3 additions & 3 deletions python/pyplugin_installer/installer.py
Expand Up @@ -287,7 +287,7 @@ def installPlugin(self, key, quiet=False):

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()
Expand Down Expand Up @@ -336,7 +336,7 @@ def installPlugin(self, key, quiet=False):
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)
Expand Down Expand Up @@ -380,7 +380,7 @@ def uninstallPlugin(self, key, quiet=False):
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)
Expand Down
2 changes: 1 addition & 1 deletion python/pyplugin_installer/installer_data.py
Expand Up @@ -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
Expand Down
Expand Up @@ -96,7 +96,7 @@ def requestFinished(self):
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():
Expand Down
2 changes: 2 additions & 0 deletions src/python/qgspythonutilsimpl.cpp
Expand Up @@ -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" );
Expand Down

0 comments on commit 4cb37b1

Please sign in to comment.