Skip to content

Commit 908d6b3

Browse files
committed
[processing]download and store help files when downloading from script/models repo
Fixes #11979
1 parent c54cd92 commit 908d6b3

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

python/plugins/processing/gui/GetScriptsAndModels.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class GetScriptsAndModelsDialog(QDialog, Ui_DlgGetScriptsAndModels):
101101
'<p>Algorithms are divided in 3 groups:</p>'
102102
'<ul><li><b>Installed:</b> Algorithms already in your system, with '
103103
'the latest version available</li>'
104-
'<li><b>Upgradable:</b> Algorithms already in your system, but with '
104+
'<li><b>Updatable:</b> Algorithms already in your system, but with '
105105
'a newer version available in the server</li>'
106106
'<li><b>Not installed:</b> Algorithms not installed in your '
107107
'system</li></ul>')
@@ -139,6 +139,7 @@ def populateTree(self):
139139
self.notinstalledItem.setIcon(0, self.icon)
140140
resources = readUrl(self.urlBase + 'list.txt').splitlines()
141141
resources = [r.split(',') for r in resources]
142+
self.resources = {f:(v,n) for f,v,n in resources}
142143
for filename, version, name in resources:
143144
treeBranch = self.getTreeBranchForState(filename, float(version))
144145
item = TreeItem(filename, name, self.icon)
@@ -177,8 +178,8 @@ def getTreeBranchForState(self, filename, version):
177178
with open(helpFile) as f:
178179
helpContent = json.load(f)
179180
currentVersion = float(helpContent[Help2Html.ALG_VERSION])
180-
except:
181-
currentVersion = 1
181+
except Exception:
182+
currentVersion = 0
182183
if version > currentVersion:
183184
return self.toupdateItem
184185
else:
@@ -209,12 +210,21 @@ def okPressed(self):
209210
path = os.path.join(self.folder, filename)
210211
with open(path, 'w') as f:
211212
f.write(code)
212-
self.progressBar.setValue(i + 1)
213213
except HTTPError:
214214
QMessageBox.critical(iface.mainWindow(),
215215
self.tr('Connection problem'),
216216
self.tr('Could not download file: %s') % filename)
217217
return
218+
url += '.help'
219+
try:
220+
html = readUrl(url)
221+
except HTTPError:
222+
html = '{"ALG_VERSION" : %s}' % self.resources[filename][0]
223+
224+
path = os.path.join(self.folder, filename + '.help')
225+
with open(path, 'w') as f:
226+
f.write(html)
227+
self.progressBar.setValue(i + 1)
218228

219229

220230
toDelete = []

0 commit comments

Comments
 (0)