Skip to content

Commit 79cb0c3

Browse files
committedDec 15, 2016
[processing] quote file paths in TauDEM provider
1 parent a848b8c commit 79cb0c3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 

‎python/plugins/processing/algs/taudem/TauDEMUtils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def taudemDescriptionPath():
102102
def executeTauDEM(command, progress):
103103
loglines = []
104104
loglines.append(TauDEMUtils.tr('TauDEM execution console output'))
105+
command = TauDEMUtils.escapeAndJoin(command)
105106
fused_command = ''.join(['"%s" ' % c for c in command])
106107
progress.setInfo(TauDEMUtils.tr('TauDEM command:'))
107108
progress.setCommand(fused_command.replace('" "', ' ').strip('"'))
@@ -118,6 +119,18 @@ def executeTauDEM(command, progress):
118119
loglines.append(line)
119120
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
120121

122+
@staticmethod
123+
def escapeAndJoin(strList):
124+
joined = ''
125+
for s in strList:
126+
if s[0] != '-' and ' ' in s:
127+
escaped = '"' + s.replace('\\', '\\\\').replace('"', '\\"') \
128+
+ '"'
129+
else:
130+
escaped = s
131+
joined += escaped + ' '
132+
return joined.strip()
133+
121134
@staticmethod
122135
def tr(string, context=''):
123136
if context == '':

0 commit comments

Comments
 (0)
Please sign in to comment.