3535from qgis .PyQt import uic
3636from qgis .PyQt .QtCore import Qt , QCoreApplication , QUrl
3737from qgis .PyQt .QtGui import QIcon , QCursor
38- from qgis .PyQt .QtWidgets import QApplication , QTreeWidgetItem , QPushButton
38+ from qgis .PyQt .QtWidgets import QApplication , QTreeWidgetItem , QPushButton , QMessageBox
3939from qgis .PyQt .QtNetwork import QNetworkReply , QNetworkRequest
4040
4141from qgis .utils import iface , show_message_log
4242from qgis .core import QgsNetworkAccessManager , QgsMessageLog
4343from qgis .gui import QgsMessageBar
4444
4545from processing .core .alglist import algList
46+ from processing .core .ProcessingConfig import ProcessingConfig
4647from processing .gui .ToolboxAction import ToolboxAction
4748from processing .gui import Help2Html
4849from processing .gui .Help2Html import getDescription , ALG_DESC , ALG_VERSION , ALG_CREATOR
@@ -65,6 +66,12 @@ def getIcon(self):
6566 return QIcon (os .path .join (pluginPath , 'images' , 'script.svg' ))
6667
6768 def execute (self ):
69+ repoUrl = ProcessingConfig .getSetting (ProcessingConfig .MODELS_SCRIPTS_REPO )
70+ if repoUrl is None or repoUrl == '' :
71+ QMessageBox .warning (None ,
72+ self .tr ('Repository error' ),
73+ self .tr ('Scripts and models repository is not configured.' ))
74+ return
6875 dlg = GetScriptsAndModelsDialog (GetScriptsAndModelsDialog .SCRIPTS )
6976 dlg .exec_ ()
7077 if dlg .updateProvider :
@@ -81,6 +88,13 @@ def getIcon(self):
8188 return QIcon (os .path .join (pluginPath , 'images' , 'r.svg' ))
8289
8390 def execute (self ):
91+ repoUrl = ProcessingConfig .getSetting (ProcessingConfig .MODELS_SCRIPTS_REPO )
92+ if repoUrl is None or repoUrl == '' :
93+ QMessageBox .warning (None ,
94+ self .tr ('Repository error' ),
95+ self .tr ('Scripts and models repository is not configured.' ))
96+ return
97+
8498 dlg = GetScriptsAndModelsDialog (GetScriptsAndModelsDialog .RSCRIPTS )
8599 dlg .exec_ ()
86100 if dlg .updateProvider :
@@ -97,6 +111,13 @@ def getIcon(self):
97111 return QIcon (os .path .join (pluginPath , 'images' , 'model.svg' ))
98112
99113 def execute (self ):
114+ repoUrl = ProcessingConfig .getSetting (ProcessingConfig .MODELS_SCRIPTS_REPO )
115+ if repoUrl is None or repoUrl == '' :
116+ QMessageBox .warning (None ,
117+ self .tr ('Repository error' ),
118+ self .tr ('Scripts and models repository is not configured.' ))
119+ return
120+
100121 dlg = GetScriptsAndModelsDialog (GetScriptsAndModelsDialog .MODELS )
101122 dlg .exec_ ()
102123 if dlg .updateProvider :
@@ -133,18 +154,20 @@ def __init__(self, resourceType):
133154
134155 self .manager = QgsNetworkAccessManager .instance ()
135156
157+ repoUrl = ProcessingConfig .getSetting (ProcessingConfig .MODELS_SCRIPTS_REPO )
158+
136159 self .resourceType = resourceType
137160 if self .resourceType == self .MODELS :
138161 self .folder = ModelerUtils .modelsFolders ()[0 ]
139- self .urlBase = 'https://raw.githubusercontent.com/qgis/QGIS-Processing/master/ models/'
162+ self .urlBase = '{}/ models/' . format ( repoUrl )
140163 self .icon = QIcon (os .path .join (pluginPath , 'images' , 'model.svg' ))
141164 elif self .resourceType == self .SCRIPTS :
142165 self .folder = ScriptUtils .scriptsFolders ()[0 ]
143- self .urlBase = 'https://raw.githubusercontent.com/qgis/QGIS-Processing/master/ scripts/'
166+ self .urlBase = '{}/ scripts/' . format ( repoUrl )
144167 self .icon = QIcon (os .path .join (pluginPath , 'images' , 'script.svg' ))
145168 else :
146169 self .folder = RUtils .RScriptsFolders ()[0 ]
147- self .urlBase = 'https://raw.githubusercontent.com/qgis/QGIS-Processing/master/ rscripts/'
170+ self .urlBase = '{}/ rscripts/' . format ( repoUrl )
148171 self .icon = QIcon (os .path .join (pluginPath , 'images' , 'r.svg' ))
149172
150173 self .lastSelectedItem = None
0 commit comments