Skip to content

Commit

Permalink
[processing] fixed handling of input filenames with non-ascii characters
Browse files Browse the repository at this point in the history
Looks like there is no problem now in SAGA when using filenames with non-ascii chars, so some code used for replacing filenames has been removed. Also some code for python2, which is not needed now.

fixes #18617
  • Loading branch information
volaya committed Jan 24, 2019
1 parent e3516ab commit fda41e3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
6 changes: 0 additions & 6 deletions python/plugins/processing/algs/saga/SagaAlgorithm.py
Expand Up @@ -396,12 +396,6 @@ def exportRasterLayer(self, parameterName, layer):
else:
filename = os.path.basename(layer.source())

validChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:'
filename = ''.join(c for c in filename if c in validChars)

if len(filename) == 0:
filename = 'layer'

destFilename = QgsProcessingUtils.generateTempFilename(filename + '.sgrd')
sessionExportedLayers[layer.source()] = destFilename
self.exportedLayers[parameterName] = destFilename
Expand Down
9 changes: 2 additions & 7 deletions python/plugins/processing/algs/saga/SagaUtils.py
Expand Up @@ -97,7 +97,7 @@ def sagaDescriptionPath():

def createSagaBatchJobFileFromSagaCommands(commands):

with open(sagaBatchJobFilename(), 'w') as fout:
with open(sagaBatchJobFilename(), 'w', encoding="utf8") as fout:
if isWindows():
fout.write('set SAGA=' + sagaPath() + '\n')
fout.write('set SAGA_MLB=' + os.path.join(sagaPath(), 'modules') + '\n')
Expand All @@ -108,12 +108,7 @@ def createSagaBatchJobFileFromSagaCommands(commands):
else:
pass
for command in commands:
try:
# Python 2
fout.write('saga_cmd ' + command.encode('utf8') + '\n')
except TypeError:
# Python 3
fout.write('saga_cmd ' + command + '\n')
fout.write('saga_cmd ' + command + '\n')

fout.write('exit')

Expand Down

0 comments on commit fda41e3

Please sign in to comment.