Skip to content

Commit

Permalink
added notice when grass help is not configured
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@194 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf committed May 29, 2012
1 parent 6d2ee69 commit 65357b2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
5 changes: 5 additions & 0 deletions src/sextante/core/WrongHelpFileException.py
@@ -0,0 +1,5 @@
class WrongHelpFileException(Exception):

def __init__(self, msg):
Exception.__init__(self)
self.msg = msg
10 changes: 7 additions & 3 deletions src/sextante/grass/GrassAlgorithm.py
Expand Up @@ -21,6 +21,7 @@
from sextante.core.SextanteUtils import SextanteUtils
from sextante.parameters.ParameterSelection import ParameterSelection
from sextante.core.LayerExporter import LayerExporter
from sextante.core.WrongHelpFileException import WrongHelpFileException

class GrassAlgorithm(GeoAlgorithm):

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

def helpFile(self):
folder = GrassUtils.grassHelpPath()
if str(folder).strip() != "":
helpfile = str(folder) + os.sep + self.grassName + ".html"
#if str(folder).strip() != "":
helpfile = str(folder) + os.sep + self.grassName + ".html"
if os.path.exists(helpfile):
return helpfile
return None
else:
raise WrongHelpFileException("Grass help folder is not correctly configured.\nPlease configure it")
#return None

def getParameterDescriptions(self):
descs = {}
Expand Down
14 changes: 9 additions & 5 deletions src/sextante/gui/ParametersDialog.py
Expand Up @@ -27,6 +27,7 @@
from sextante.outputs.OutputRaster import OutputRaster
from sextante.outputs.OutputVector import OutputVector
from sextante.outputs.OutputTable import OutputTable
from sextante.core.WrongHelpFileException import WrongHelpFileException

try:
_fromUtf8 = QtCore.QString.fromUtf8
Expand Down Expand Up @@ -79,11 +80,14 @@ def setupUi(self, dialog, alg):
QtCore.QMetaObject.connectSlotsByName(dialog)

def showHelp(self):
if self.alg.helpFile():
dlg = HTMLViewerDialog(self.alg.helpFile())
dlg.exec_()
else:
QMessageBox.warning(self.dialog, "No help available", "No help is available for the current algorithm.")
try:
if self.alg.helpFile():
dlg = HTMLViewerDialog(self.alg.helpFile())
dlg.exec_()
else:
QMessageBox.warning(self.dialog, "No help available", "No help is available for the current algorithm.")
except WrongHelpFileException, e:
QMessageBox.warning(self.dialog, "Help", e.msg)


def setParamValues(self):
Expand Down
14 changes: 9 additions & 5 deletions src/sextante/modeler/ModelerParametersDialog.py
Expand Up @@ -23,6 +23,7 @@
from sextante.parameters.ParameterFile import ParameterFile
from sextante.outputs.OutputFile import OutputFile
from sextante.gui.HTMLViewerDialog import HTMLViewerDialog
from sextante.core.WrongHelpFileException import WrongHelpFileException

class ModelerParametersDialog(QtGui.QDialog):

Expand Down Expand Up @@ -73,11 +74,14 @@ def setupUi(self):
QtCore.QMetaObject.connectSlotsByName(self)

def showHelp(self):
if self.alg.helpFile():
dlg = HTMLViewerDialog(self.alg.helpFile())
dlg.exec_()
else:
QMessageBox.warning(self.dialog, "No help available", "No help is available for this algorithm.")
try:
if self.alg.helpFile():
dlg = HTMLViewerDialog(self.alg.helpFile())
dlg.exec_()
else:
QMessageBox.warning(self.dialog, "No help available", "No help is available for the current algorithm.")
except WrongHelpFileException, e:
QMessageBox.warning(self.dialog, "Help", e.msg)

def getRasterLayers(self):
layers = []
Expand Down

0 comments on commit 65357b2

Please sign in to comment.