Skip to content

Commit

Permalink
fixed problem when running grass in modeler (wrong output names, it w…
Browse files Browse the repository at this point in the history
…as a problem introduced by the grass session functionalities)

reverted shell=true in R execution
Removed help files help menu
  • Loading branch information
volaya committed Nov 14, 2012
1 parent 81807d4 commit 10a57ad
Show file tree
Hide file tree
Showing 838 changed files with 41 additions and 50,485 deletions.
18 changes: 11 additions & 7 deletions python/plugins/sextante/SextantePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ def initGui(self):
QObject.connect(self.resultsAction, SIGNAL("triggered()"), self.openResults)
self.menu.addAction(self.resultsAction)

self.helpAction = QAction(QIcon(":/sextante/images/help.png"),
QCoreApplication.translate("SEXTANTE", "&SEXTANTE help"),
self.iface.mainWindow())
QObject.connect(self.helpAction, SIGNAL("triggered()"), self.openHelp)
self.menu.addAction(self.helpAction)
#=======================================================================
# self.helpAction = QAction(QIcon(":/sextante/images/help.png"),
# QCoreApplication.translate("SEXTANTE", "&SEXTANTE help"),
# self.iface.mainWindow())
# QObject.connect(self.helpAction, SIGNAL("triggered()"), self.openHelp)
# self.menu.addAction(self.helpAction)
#=======================================================================

menuBar = self.iface.mainWindow().menuBar()
menuBar.insertMenu(menuBar.actions()[-1], self.menu)
Expand Down Expand Up @@ -137,5 +139,7 @@ def openConfig(self):
dlg = ConfigDialog(self.toolbox)
dlg.exec_()

def openHelp(self):
QDesktopServices.openUrl(QUrl(os.path.dirname(__file__) + "/help/index.html"))
#===========================================================================
# def openHelp(self):
# QDesktopServices.openUrl(QUrl(os.path.dirname(__file__) + "/help/index.html"))
#===========================================================================
4 changes: 2 additions & 2 deletions python/plugins/sextante/core/Sextante.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from sextante.gdal.GdalOgrAlgorithmProvider import GdalOgrAlgorithmProvider
from sextante.mmqgisx.MMQGISXAlgorithmProvider import MMQGISXAlgorithmProvider
from sextante.otb.OTBAlgorithmProvider import OTBAlgorithmProvider
from sextante.pymorph.PymorphAlgorithmProvider import PymorphAlgorithmProvider
#from sextante.pymorph.PymorphAlgorithmProvider import PymorphAlgorithmProvider
from sextante.r.RAlgorithmProvider import RAlgorithmProvider
from sextante.saga.SagaAlgorithmProvider import SagaAlgorithmProvider
from sextante.script.ScriptAlgorithmProvider import ScriptAlgorithmProvider
Expand Down Expand Up @@ -120,7 +120,7 @@ def initialize():
Sextante.addProvider(FToolsAlgorithmProvider())
Sextante.addProvider(ModelerOnlyAlgorithmProvider())
Sextante.addProvider(GdalOgrAlgorithmProvider())
Sextante.addProvider(PymorphAlgorithmProvider())
#Sextante.addProvider(PymorphAlgorithmProvider())
Sextante.addProvider(LidarToolsAlgorithmProvider())
Sextante.addProvider(OTBAlgorithmProvider())
Sextante.addProvider(RAlgorithmProvider())
Expand Down
22 changes: 12 additions & 10 deletions python/plugins/sextante/grass/GrassAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
import uuid

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down Expand Up @@ -254,13 +255,17 @@ def processAlgorithm(self, progress):
else:
command+=(" " + param.name + "=" + str(param.value));

uniqueSufix = str(uuid.uuid4()).replace("-","");
for out in self.outputs:
if isinstance(out, OutputFile):
command+=(" " + out.name + "=\"" + out.value + "\"");
else:
command += (" " + out.name)
out.name += ("_"+str(len(self.exportedLayers))) # make sure output is unique within a session
command += ("=" + out.name)
#an output name to make sure it is unique if the session uses this algorithm several times
uniqueOutputName = out.name + uniqueSufix
command += (" " + out.name + "=" + uniqueOutputName)
# add output file to exported layers, to indicate that they are present in GRASS
self.exportedLayers[out.value]= uniqueOutputName


command += " --overwrite"
commands.append(command)
Expand All @@ -270,24 +275,21 @@ def processAlgorithm(self, progress):
if isinstance(out, OutputRaster):
filename = out.value
#Raster layer output: adjust region to layer before exporting
commands.append("g.region rast=" + out.name)
commands.append("g.region rast=" + out.name + uniqueSufix)
command = "r.out.gdal -c createopt=\"TFW=YES,COMPRESS=LZW\""
command += " input="
command += out.name
command += out.name + uniqueSufix
command += " output=\"" + filename + "\""
commands.append(command)
# add output file to exported layers, to indicate that they are present in GRASS
self.exportedLayers[filename]= out.name

if isinstance(out, OutputVector):
filename = out.value
command = "v.out.ogr -ce input=" + out.name
command = "v.out.ogr -ce input=" + out.name + uniqueSufix
command += " dsn=\"" + os.path.dirname(out.value) + "\""
command += " format=ESRI_Shapefile"
command += " olayer=" + os.path.basename(out.value)[:-4]
command += " type=auto"
commands.append(command)
# add output file to exported layers
self.exportedLayers[filename]= out.name

#4 Run GRASS
loglines = []
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/GrassUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def createGrassBatchJobFileFromGrassCommands(commands):

@staticmethod
def grassMapsetFolder():
tempfolder = os.path.join(os.path.expanduser("~"), "sextante", "tempdata", "grassdata", "temp_location")
tempfolder = os.path.join(SextanteUtils.tempFolder(), "grassdata", "temp_location")
mkdir(tempfolder)
return tempfolder

Expand Down
20 changes: 12 additions & 8 deletions python/plugins/sextante/gui/SextanteToolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
import webbrowser

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down Expand Up @@ -86,14 +87,17 @@ def setupUi(self):
QMetaObject.connectSlotsByName(self)

def configureProviders(self):
#QDesktopServices.openUrl(QUrl(os.path.join(os.path.dirname(__file__), os.path.pardir) + "/help/3rdParty.html"))
filename = os.path.join(os.path.dirname(__file__), "..", "help", "3rdParty.html")
if os.name == "nt":
os.startfile(filename)
elif sys.platform == "darwin":
subprocess.Popen(('open', filename))
else:
subprocess.call(('xdg-open', filename))
webbrowser.open("http://docs.qgis.org/html/en/user_manual/sextante/3rdParty.html")
#=======================================================================
# #QDesktopServices.openUrl(QUrl(os.path.join(os.path.dirname(__file__), os.path.pardir) + "/help/3rdParty.html"))
# filename = os.path.join(os.path.dirname(__file__), "..", "help", "3rdParty.html")
# if os.name == "nt":
# os.startfile(filename)
# elif sys.platform == "darwin":
# subprocess.Popen(('open', filename))
# else:
# subprocess.call(('xdg-open', filename))
#=======================================================================

def showPopupMenu(self,point):
item = self.algorithmTree.itemAt(point)
Expand Down
4 changes: 0 additions & 4 deletions python/plugins/sextante/help/.buildinfo

This file was deleted.

0 comments on commit 10a57ad

Please sign in to comment.