Skip to content
Permalink
Browse files

[sextante]improved information when missing 3rd party app before runn…

…ing algorithm
  • Loading branch information
volaya committed Apr 12, 2013
1 parent bcd1c91 commit 448d860d5ae47c5917ffbc3ca52075b9a1c48879
@@ -52,6 +52,12 @@
from sextante.taudem.TauDEMAlgorithmProvider import TauDEMAlgorithmProvider
from sextante.admintools.AdminToolsAlgorithmProvider import AdminToolsAlgorithmProvider

from threading import settrace

import sys
sys.path.append("D:\eclipse\plugins\org.python.pydev_2.6.0.2012062818\pysrc")
from pydevd import *

This comment has been minimized.

Copy link
@timlinux

timlinux Apr 13, 2013

Member

Can we remove this again - it causes an error on start https://gist.github.com/timlinux/5377272


class Sextante:

iface = None
@@ -268,6 +274,8 @@ def runAlgorithm(algOrName, onFinish, *args):
return
else:
i = 0

settrace()
for param in alg.parameters:
if not param.hidden:
if not param.setValue(args[i]):
@@ -55,14 +55,14 @@ class SextanteConfig():
def initialize():
icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/alg.png")
SextanteConfig.settingIcons["General"] = icon
SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_THREADS, "Run algorithms in a new thread (still unstable)", False))
SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_THREADS, "Run algorithms in a new thread (still unstable)", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_DEBUG_IN_DIALOG, "Show debug information and commands executed in the execution dialog's Log panel (threaded execution only)", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.KEEP_DIALOG_OPEN, "Keep dialog open after running an algorithm", False))
SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_SELECTED, "Use only selected features", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.TABLE_LIKE_PARAM_PANEL, "Show table-like parameter panels", False))
SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_FILENAME_AS_LAYER_NAME, "Use filename as layer name", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_RECENT_ALGORITHMS, "Show recently executed algorithms", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_CATEGORIES, "Use categories to classify algorithms, instead of providers", False))
SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_CATEGORIES, "Use categories to classify algorithms, instead of providers", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.OUTPUT_FOLDER, "Output folder", SextanteUtils.tempFolder()))
SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_CRS_DEF, "Show layer CRS definition in selection boxes", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.WARN_UNMATCHING_CRS, "Warn before executing if layer CRS's do not match", True))
@@ -427,6 +427,15 @@ def getTempFilename(self):

def commandLineName(self):
return "grass:" + self.name[:self.name.find(" ")]

def checkBeforeOpeningParametersDialog(self):
msg = GrassUtils.checkGrassIsInstalled()
if msg is not None:
html = ("<p>This algorithm requires GRASS to be run."
"Unfortunately, it seems that GRASS is not installed in your system, or it is not correctly configured to be used from QGIS</p>")
html += '<p><a href= "http://docs.qgis.org/html/en/docs/user_manual/sextante/3rdParty.html">Click here</a> to know more about how to install and configure GRASS to be used with SEXTANTE</p>'
return html


def checkParameterValuesBeforeExecuting(self):
name = self.commandLineName().replace('.','_')[len('grass:'):]
@@ -319,7 +319,7 @@ def checkGrassIsInstalled(ignoreRegistrySettings=False):
path = GrassUtils.grassPath()
if path == "":
return "GRASS folder is not configured.\nPlease configure it before running SAGA algorithms."
cmdpath = os.path.join(path, "bin\r.out.exe")
cmdpath = os.path.join(path, "bin","r.out.gdal.exe")
if not os.path.exists(cmdpath):
return ("The specified GRASS folder does not contain a valid set of GRASS modules.\n"
+ "Please, go to the SEXTANTE settings dialog, and check that the GRASS\n"
@@ -332,7 +332,7 @@ def checkGrassIsInstalled(ignoreRegistrySettings=False):
return

try:
from sextante.core.Sextante import runalg
from sextante import runalg
result = runalg("grass:v.voronoi", points(),False,False,"270778.60198,270855.745301,4458921.97814,4458983.8488",-1,0.0001,None)
if not os.path.exists(result['output']):
return "It seems that GRASS is not correctly installed and configured in your system.\nPlease install it before running GRASS algorithms."
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
MessingDependencyDialog.py
---------------------
Date : April 2013
Copyright : (C) 2013 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
import webbrowser

__author__ = 'Victor Olaya'
__date__ = 'April 2013'
__copyright__ = '(C) 2013, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from PyQt4 import QtCore, QtGui, QtWebKit
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class MissingDependencyDialog(QtGui.QDialog):
def __init__(self, msg):
QtGui.QDialog.__init__(self, None, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
self.msg = "<h3>Missing dependency.This algorithm cannot be run :-( </h3>" + msg
self.setupUi()

def setupUi(self):
self.resize(500,300)
self.setWindowTitle("Missing dependency")
layout = QVBoxLayout()
webView = QtWebKit.QWebView()
webView.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
webView.connect(webView, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked)
webView.setHtml(self.msg)
closeButton = QtGui.QPushButton()
closeButton.setText("Close")
QObject.connect(closeButton, QtCore.SIGNAL("clicked()"), self.closeButtonPressed)
layout.addWidget(webView)
layout.addWidget(closeButton)
self.setLayout(layout)
QtCore.QMetaObject.connectSlotsByName(self)

def linkClicked(self, url):
webbrowser.open(str(url.toString()))

def closeButtonPressed(self):
self.close()
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
@@ -26,6 +27,7 @@
from PyQt4.QtGui import *

import webbrowser
from sextante.gui.MissingDependencyDialog import MissingDependencyDialog
from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.modeler.Providers import Providers
from sextante.gui.AlgorithmClassification import AlgorithmDecorator
@@ -115,7 +117,9 @@ def executeAlgorithm(self):
alg = Sextante.getAlgorithm(item.alg.commandLineName())
message = alg.checkBeforeOpeningParametersDialog()
if message:
QMessageBox.warning(self, self.tr("Warning"), message)
dlg = MissingDependencyDialog(message)
dlg.exec_()
#QMessageBox.warning(self, self.tr("Warning"), message)
return
alg = alg.getCopy()
dlg = alg.getCustomParametersDialog()
@@ -96,6 +96,7 @@ def defineCharacteristicsFromFile(self):
self.cmdname = tokens[1]
else:
self.cmdname = self.name
self.name = self.name[0].upper() + self.name[1:].lower()
line = lines.readline().strip("\n").strip()
self.undecoratedGroup = line
self.group = SagaGroupNameDecorator.getDecoratedName(self.undecoratedGroup)
@@ -356,7 +357,12 @@ def exportRasterLayer(self, layer):


def checkBeforeOpeningParametersDialog(self):
return SagaUtils.checkSagaIsInstalled()
msg = SagaUtils.checkSagaIsInstalled()
if msg is not None:
html = ("<p>This algorithm requires SAGA to be run."
"Unfortunately, it seems that SAGA is not installed in your system, or it is not correctly configured to be used from QGIS</p>")
html += '<p><a href= "http://docs.qgis.org/html/en/docs/user_manual/sextante/3rdParty.html">Click here</a> to know more about how to install and configure SAGA to be used with SEXTANTE</p>'
return html


def checkParameterValuesBeforeExecuting(self):
@@ -142,7 +142,7 @@ def checkSagaIsInstalled(ignoreRegistrySettings=False):
return

try:
from sextante.core.Sextante import runalg
from sextante import runalg
result = runalg("saga:thiessenpolygons", points(), None)
if not os.path.exists(result['POLYGONS']):
return "It seems that SAGA is not correctly installed in your system.\nPlease install it before running SAGA algorithms."

0 comments on commit 448d860

Please sign in to comment.
You can’t perform that action at this time.