Skip to content

Commit 65357b2

Browse files
author
volayaf
committed
added notice when grass help is not configured
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@194 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
1 parent 6d2ee69 commit 65357b2

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class WrongHelpFileException(Exception):
2+
3+
def __init__(self, msg):
4+
Exception.__init__(self)
5+
self.msg = msg

src/sextante/grass/GrassAlgorithm.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from sextante.core.SextanteUtils import SextanteUtils
2222
from sextante.parameters.ParameterSelection import ParameterSelection
2323
from sextante.core.LayerExporter import LayerExporter
24+
from sextante.core.WrongHelpFileException import WrongHelpFileException
2425

2526
class GrassAlgorithm(GeoAlgorithm):
2627

@@ -40,10 +41,13 @@ def getIcon(self):
4041

4142
def helpFile(self):
4243
folder = GrassUtils.grassHelpPath()
43-
if str(folder).strip() != "":
44-
helpfile = str(folder) + os.sep + self.grassName + ".html"
44+
#if str(folder).strip() != "":
45+
helpfile = str(folder) + os.sep + self.grassName + ".html"
46+
if os.path.exists(helpfile):
4547
return helpfile
46-
return None
48+
else:
49+
raise WrongHelpFileException("Grass help folder is not correctly configured.\nPlease configure it")
50+
#return None
4751

4852
def getParameterDescriptions(self):
4953
descs = {}

src/sextante/gui/ParametersDialog.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from sextante.outputs.OutputRaster import OutputRaster
2828
from sextante.outputs.OutputVector import OutputVector
2929
from sextante.outputs.OutputTable import OutputTable
30+
from sextante.core.WrongHelpFileException import WrongHelpFileException
3031

3132
try:
3233
_fromUtf8 = QtCore.QString.fromUtf8
@@ -79,11 +80,14 @@ def setupUi(self, dialog, alg):
7980
QtCore.QMetaObject.connectSlotsByName(dialog)
8081

8182
def showHelp(self):
82-
if self.alg.helpFile():
83-
dlg = HTMLViewerDialog(self.alg.helpFile())
84-
dlg.exec_()
85-
else:
86-
QMessageBox.warning(self.dialog, "No help available", "No help is available for the current algorithm.")
83+
try:
84+
if self.alg.helpFile():
85+
dlg = HTMLViewerDialog(self.alg.helpFile())
86+
dlg.exec_()
87+
else:
88+
QMessageBox.warning(self.dialog, "No help available", "No help is available for the current algorithm.")
89+
except WrongHelpFileException, e:
90+
QMessageBox.warning(self.dialog, "Help", e.msg)
8791

8892

8993
def setParamValues(self):

src/sextante/modeler/ModelerParametersDialog.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from sextante.parameters.ParameterFile import ParameterFile
2424
from sextante.outputs.OutputFile import OutputFile
2525
from sextante.gui.HTMLViewerDialog import HTMLViewerDialog
26+
from sextante.core.WrongHelpFileException import WrongHelpFileException
2627

2728
class ModelerParametersDialog(QtGui.QDialog):
2829

@@ -73,11 +74,14 @@ def setupUi(self):
7374
QtCore.QMetaObject.connectSlotsByName(self)
7475

7576
def showHelp(self):
76-
if self.alg.helpFile():
77-
dlg = HTMLViewerDialog(self.alg.helpFile())
78-
dlg.exec_()
79-
else:
80-
QMessageBox.warning(self.dialog, "No help available", "No help is available for this algorithm.")
77+
try:
78+
if self.alg.helpFile():
79+
dlg = HTMLViewerDialog(self.alg.helpFile())
80+
dlg.exec_()
81+
else:
82+
QMessageBox.warning(self.dialog, "No help available", "No help is available for the current algorithm.")
83+
except WrongHelpFileException, e:
84+
QMessageBox.warning(self.dialog, "Help", e.msg)
8185

8286
def getRasterLayers(self):
8387
layers = []

0 commit comments

Comments
 (0)