Skip to content

Commit

Permalink
[processing] add missed escapeAndJoin function to TauDEM provider
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Mar 28, 2017
1 parent 140a01f commit ad86dc0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion python/plugins/processing/algs/taudem/TauDEMUtils.py
Expand Up @@ -102,7 +102,7 @@ def taudemDescriptionPath():
def executeTauDEM(command, progress): def executeTauDEM(command, progress):
loglines = [] loglines = []
loglines.append(TauDEMUtils.tr('TauDEM execution console output')) loglines.append(TauDEMUtils.tr('TauDEM execution console output'))
command = escapeAndJoin(command) command = TauDEMUtils.escapeAndJoin(command)
fused_command = ''.join(['"%s" ' % c for c in command]) fused_command = ''.join(['"%s" ' % c for c in command])
progress.setInfo(TauDEMUtils.tr('TauDEM command:')) progress.setInfo(TauDEMUtils.tr('TauDEM command:'))
progress.setCommand(fused_command.replace('" "', ' ').strip('"')) progress.setCommand(fused_command.replace('" "', ' ').strip('"'))
Expand All @@ -124,3 +124,15 @@ def tr(string, context=''):
if context == '': if context == '':
context = 'TauDEMUtils' context = 'TauDEMUtils'
return QCoreApplication.translate(context, string) return QCoreApplication.translate(context, string)

@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()

0 comments on commit ad86dc0

Please sign in to comment.