mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Cleanup qgis.utils.home_plugin_path
This commit is contained in:
parent
e9cbd075b7
commit
98c19b38ac
@ -44,9 +44,18 @@ from qgis.PyQt.QtNetwork import QNetworkRequest
|
||||
|
||||
from qgis.core import Qgis, QgsApplication, QgsMessageLog, QgsNetworkAccessManager, QgsSettings, QgsSettingsTree, QgsNetworkRequestParameters
|
||||
from qgis.gui import QgsMessageBar, QgsPasswordLineEdit, QgsHelp
|
||||
from qgis.utils import (iface, startPlugin, unloadPlugin, loadPlugin, OverrideCursor,
|
||||
reloadPlugin, updateAvailablePlugins, plugins_metadata_parser, isPluginLoaded)
|
||||
from qgis import utils
|
||||
from qgis.utils import (
|
||||
iface,
|
||||
startPlugin,
|
||||
unloadPlugin,
|
||||
loadPlugin,
|
||||
OverrideCursor,
|
||||
reloadPlugin,
|
||||
updateAvailablePlugins,
|
||||
plugins_metadata_parser,
|
||||
isPluginLoaded,
|
||||
HOME_PLUGIN_PATH
|
||||
)
|
||||
from .installer_data import (repositories, plugins, officialRepo,
|
||||
reposGroup, removeDir)
|
||||
from .qgsplugininstallerinstallingdialog import QgsPluginInstallerInstallingDialog
|
||||
@ -323,7 +332,7 @@ class QgsPluginInstaller(QObject):
|
||||
dlg = QgsPluginInstallerInstallingDialog(iface.mainWindow(), plugin, stable=stable)
|
||||
dlg.exec_()
|
||||
|
||||
plugin_path = utils.home_plugin_path + "/" + key
|
||||
plugin_path = HOME_PLUGIN_PATH + "/" + key
|
||||
if dlg.result():
|
||||
error = True
|
||||
infoString = (self.tr("Plugin installation failed"), dlg.result())
|
||||
@ -387,7 +396,7 @@ class QgsPluginInstaller(QObject):
|
||||
dlg.exec_()
|
||||
if dlg.result():
|
||||
# revert installation
|
||||
pluginDir = utils.home_plugin_path + "/" + plugin["id"]
|
||||
pluginDir = HOME_PLUGIN_PATH + "/" + plugin["id"]
|
||||
result = removeDir(pluginDir)
|
||||
if QDir(pluginDir).exists():
|
||||
error = True
|
||||
@ -436,7 +445,7 @@ class QgsPluginInstaller(QObject):
|
||||
unloadPlugin(key)
|
||||
except:
|
||||
pass
|
||||
pluginDir = utils.home_plugin_path + "/" + plugin["id"]
|
||||
pluginDir = HOME_PLUGIN_PATH + "/" + plugin["id"]
|
||||
result = removeDir(pluginDir)
|
||||
if result:
|
||||
QApplication.restoreOverrideCursor()
|
||||
@ -612,7 +621,7 @@ class QgsPluginInstaller(QObject):
|
||||
QgsHelp.openHelp("plugins/plugins.html#the-install-from-zip-tab")
|
||||
return
|
||||
|
||||
pluginsDirectory = utils.home_plugin_path
|
||||
pluginsDirectory = HOME_PLUGIN_PATH
|
||||
if not QDir(pluginsDirectory).exists():
|
||||
QDir().mkpath(pluginsDirectory)
|
||||
|
||||
|
||||
@ -42,7 +42,11 @@ import configparser
|
||||
import qgis.utils
|
||||
from qgis.core import QgsNetworkAccessManager, QgsApplication
|
||||
from qgis.gui import QgsGui
|
||||
from qgis.utils import iface, plugin_paths
|
||||
from qgis.utils import (
|
||||
iface,
|
||||
plugin_paths,
|
||||
HOME_PLUGIN_PATH
|
||||
)
|
||||
from .version_compare import pyQgisVersion, compareVersions, normalizeVersion, isCompatible
|
||||
|
||||
|
||||
@ -133,7 +137,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 = qgis.utils.home_plugin_path
|
||||
pluginDir = HOME_PLUGIN_PATH
|
||||
if not QDir(pluginDir).exists():
|
||||
QDir().mkpath(pluginDir)
|
||||
return result
|
||||
|
||||
@ -30,7 +30,7 @@ from qgis.PyQt.QtWidgets import QDialog
|
||||
from qgis.PyQt.QtNetwork import QNetworkRequest, QNetworkReply
|
||||
|
||||
from qgis.core import QgsNetworkAccessManager, QgsApplication, QgsNetworkRequestParameters
|
||||
from qgis import utils
|
||||
from qgis.utils import HOME_PLUGIN_PATH
|
||||
|
||||
from .ui_qgsplugininstallerinstallingbase import Ui_QgsPluginInstallerInstallingDialogBase
|
||||
from .installer_data import removeDir, repositories
|
||||
@ -142,7 +142,7 @@ class QgsPluginInstallerInstallingDialog(QDialog, Ui_QgsPluginInstallerInstallin
|
||||
self.file.close()
|
||||
self.stateChanged(0)
|
||||
reply.deleteLater()
|
||||
pluginDir = utils.home_plugin_path
|
||||
pluginDir = HOME_PLUGIN_PATH
|
||||
tmpPath = self.file.fileName()
|
||||
# make sure that the parent directory exists
|
||||
if not QDir(pluginDir).exists():
|
||||
|
||||
@ -222,6 +222,9 @@ def initInterface(pointer):
|
||||
#######################
|
||||
# PLUGINS
|
||||
|
||||
# The current path for home directory Python plugins.
|
||||
HOME_PLUGIN_PATH: Optional[str] = None
|
||||
|
||||
# list of plugin paths. it gets filled in by the QGIS python library
|
||||
plugin_paths = []
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ bool QgsPythonUtilsImpl::checkSystemImports()
|
||||
// tell the utils script where to look for the plugins
|
||||
runString( QStringLiteral( "qgis.utils.plugin_paths = [%1]" ).arg( pluginpaths.join( ',' ) ) );
|
||||
runString( QStringLiteral( "qgis.utils.sys_plugin_path = \"%1\"" ).arg( pluginsPath() ) );
|
||||
runString( QStringLiteral( "qgis.utils.home_plugin_path = %1" ).arg( homePluginsPath() ) ); // note - homePluginsPath() returns a python expression, not a string literal
|
||||
runString( QStringLiteral( "qgis.utils.HOME_PLUGIN_PATH = %1" ).arg( homePluginsPath() ) ); // note - homePluginsPath() returns a python expression, not a string literal
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
runString( "if oldhome: os.environ['HOME']=oldhome\n" );
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user