3232
3333from PyQt4 import uic
3434from PyQt4 .QtCore import Qt , QCoreApplication , QUrl
35- from PyQt4 .QtGui import QIcon , QCursor , QApplication , QTreeWidgetItem , QPushButton
35+ from PyQt4 .QtGui import QIcon , QCursor , QApplication , QTreeWidgetItem , QPushButton , QMessageBox
3636from PyQt4 .QtNetwork import QNetworkReply , QNetworkRequest
3737
3838from qgis .utils import iface , show_message_log
3939from qgis .core import QgsNetworkAccessManager , QgsMessageLog
4040from qgis .gui import QgsMessageBar
4141
42+ from processing .core .ProcessingConfig import ProcessingConfig
4243from processing .gui .ToolboxAction import ToolboxAction
4344from processing .script .ScriptUtils import ScriptUtils
4445from processing .algs .r .RUtils import RUtils
@@ -61,6 +62,13 @@ def getIcon(self):
6162 return QIcon (os .path .join (pluginPath , 'images' , 'script.png' ))
6263
6364 def execute (self ):
65+ repoUrl = ProcessingConfig .getSetting (ProcessingConfig .MODELS_SCRIPTS_REPO )
66+ if repoUrl is None or repoUrl == '' :
67+ QMessageBox .warning (None ,
68+ self .tr ('Repository error' ),
69+ self .tr ('Scripts and models repository is not configured.' ))
70+ return
71+
6472 dlg = GetScriptsAndModelsDialog (GetScriptsAndModelsDialog .SCRIPTS )
6573 dlg .exec_ ()
6674 if dlg .updateToolbox :
@@ -77,6 +85,13 @@ def getIcon(self):
7785 return QIcon (os .path .join (pluginPath , 'images' , 'r.svg' ))
7886
7987 def execute (self ):
88+ repoUrl = ProcessingConfig .getSetting (ProcessingConfig .MODELS_SCRIPTS_REPO )
89+ if repoUrl is None or repoUrl == '' :
90+ QMessageBox .warning (None ,
91+ self .tr ('Repository error' ),
92+ self .tr ('Scripts and models repository is not configured.' ))
93+ return
94+
8095 dlg = GetScriptsAndModelsDialog (GetScriptsAndModelsDialog .RSCRIPTS )
8196 dlg .exec_ ()
8297 if dlg .updateToolbox :
@@ -93,6 +108,13 @@ def getIcon(self):
93108 return QIcon (os .path .join (pluginPath , 'images' , 'model.png' ))
94109
95110 def execute (self ):
111+ repoUrl = ProcessingConfig .getSetting (ProcessingConfig .MODELS_SCRIPTS_REPO )
112+ if repoUrl is None or repoUrl == '' :
113+ QMessageBox .warning (None ,
114+ self .tr ('Repository error' ),
115+ self .tr ('Scripts and models repository is not configured.' ))
116+ return
117+
96118 dlg = GetScriptsAndModelsDialog (GetScriptsAndModelsDialog .MODELS )
97119 dlg .exec_ ()
98120 if dlg .updateToolbox :
@@ -125,18 +147,20 @@ def __init__(self, resourceType):
125147 self .setupUi (self )
126148 self .manager = QgsNetworkAccessManager .instance ()
127149
150+ repoUrl = ProcessingConfig .getSetting (ProcessingConfig .MODELS_SCRIPTS_REPO )
151+
128152 self .resourceType = resourceType
129153 if self .resourceType == self .MODELS :
130154 self .folder = ModelerUtils .modelsFolder ()
131- self .urlBase = 'https://raw.githubusercontent.com/qgis/QGIS-Processing/master/ models/'
155+ self .urlBase = '{}/ models/' . format ( repoUrl )
132156 self .icon = QIcon (os .path .join (pluginPath , 'images' , 'model.png' ))
133157 elif self .resourceType == self .SCRIPTS :
134158 self .folder = ScriptUtils .scriptsFolder ()
135- self .urlBase = 'https://raw.githubusercontent.com/qgis/QGIS-Processing/master/ scripts/'
159+ self .urlBase = '{}/ scripts/' . format ( repoUrl )
136160 self .icon = QIcon (os .path .join (pluginPath , 'images' , 'script.png' ))
137161 else :
138162 self .folder = RUtils .RScriptsFolder ()
139- self .urlBase = 'https://raw.githubusercontent.com/qgis/QGIS-Processing/master/ rscripts/'
163+ self .urlBase = '{}/ rscripts/' . format ( repoUrl )
140164 self .icon = QIcon (os .path .join (pluginPath , 'images' , 'r.svg' ))
141165
142166 self .lastSelectedItem = None
0 commit comments