Skip to content

Commit

Permalink
[processing] quote file paths in TauDEM provider
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Dec 15, 2016
1 parent a848b8c commit 79cb0c3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions python/plugins/processing/algs/taudem/TauDEMUtils.py
Expand Up @@ -102,6 +102,7 @@ def taudemDescriptionPath():
def executeTauDEM(command, progress):
loglines = []
loglines.append(TauDEMUtils.tr('TauDEM execution console output'))
command = TauDEMUtils.escapeAndJoin(command)
fused_command = ''.join(['"%s" ' % c for c in command])
progress.setInfo(TauDEMUtils.tr('TauDEM command:'))
progress.setCommand(fused_command.replace('" "', ' ').strip('"'))
Expand All @@ -118,6 +119,18 @@ def executeTauDEM(command, progress):
loglines.append(line)
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)

@staticmethod
def escapeAndJoin(strList):
joined = ''
for s in strList:
if s[0] != '-' and ' ' in s:
escaped = '"' + s.replace('\\', '\\\\').replace('"', '\\"') \
+ '"'
else:
escaped = s
joined += escaped + ' '
return joined.strip()

@staticmethod
def tr(string, context=''):
if context == '':
Expand Down

0 comments on commit 79cb0c3

Please sign in to comment.