Skip to content

Commit

Permalink
[processing] fixed issues with spaces in paths when using GRASS algor…
Browse files Browse the repository at this point in the history
…ithms
  • Loading branch information
volaya committed Oct 1, 2015
1 parent a8f8cfe commit 5d4a8d9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions python/plugins/processing/algs/grass/GrassAlgorithm.py
Expand Up @@ -300,21 +300,22 @@ def processAlgorithm(self, progress):
for param in self.parameters:
if param.value is None or param.value == '':
continue
if param.name in [self.GRASS_REGION_CELLSIZE_PARAMETER, self.GRASS_REGION_EXTENT_PARAMETER, self.GRASS_MIN_AREA_PARAMETER, self.GRASS_SNAP_TOLERANCE_PARAMETER, self.GRASS_OUTPUT_TYPE_PARAMETER, self.GRASS_REGION_ALIGN_TO_RESOLUTION]:
if param.name in [self.GRASS_REGION_CELLSIZE_PARAMETER, self.GRASS_REGION_EXTENT_PARAMETER,
self.GRASS_MIN_AREA_PARAMETER, self.GRASS_SNAP_TOLERANCE_PARAMETER,
self.GRASS_OUTPUT_TYPE_PARAMETER, self.GRASS_REGION_ALIGN_TO_RESOLUTION]:
continue
if isinstance(param, (ParameterRaster, ParameterVector)):
value = param.value
if value in self.exportedLayers.keys():
command += ' ' + param.name + '=' \
+ self.exportedLayers[value]
command += ' %s="%s"' %(param.name, self.exportedLayers[value])
else:
command += ' ' + param.name + '=' + value
command += ' %s="%s"' % (param.name, value)
elif isinstance(param, ParameterMultipleInput):
s = param.value
for layer in self.exportedLayers.keys():
s = s.replace(layer, self.exportedLayers[layer])
s = s.replace(';', ',')
command += ' ' + param.name + '=' + s
command += ' %s="%s"' % (param.name, s)
elif isinstance(param, ParameterBoolean):
if param.value:
command += ' ' + param.name
Expand Down Expand Up @@ -378,7 +379,7 @@ def processAlgorithm(self, progress):
command = 'v.out.ogr -s -c -e -z input=' + out.name + uniqueSufix
command += ' dsn="' + os.path.dirname(filename) + '"'
command += ' format=ESRI_Shapefile'
command += ' olayer=' + os.path.splitext(os.path.basename(filename))[0]
command += ' olayer="%s"' % os.path.splitext(os.path.basename(filename))[0]
typeidx = \
self.getParameterValue(self.GRASS_OUTPUT_TYPE_PARAMETER)
outtype = ('auto' if typeidx
Expand Down Expand Up @@ -439,8 +440,8 @@ def exportVectorLayer(self, orgFilename):
command += ' min_area=' + unicode(min_area)
snap = self.getParameterValue(self.GRASS_SNAP_TOLERANCE_PARAMETER)
command += ' snap=' + unicode(snap)
command += ' dsn="' + os.path.dirname(filename) + '"'
command += ' layer=' + os.path.basename(filename)[:-4]
command += ' dsn="%s"' % os.path.dirname(filename)
command += ' layer="%s"' % os.path.splitext(os.path.basename(filename)[:-4])[0]
command += ' output=' + destFilename
command += ' --overwrite -o'
return command
Expand Down

0 comments on commit 5d4a8d9

Please sign in to comment.