1

I am using Python to simplify some commands in Maven. I have this script which calls mvn test in debug mode.

from subprocess import call
commands = []
commands.append("mvn")
commands.append("test")
commands.append("-Dmaven.surefire.debug=\"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE\"")
call(commands)

The problem is with line -Dmaven.surefire.debug which accepts parameter which has to be in quotas and I don't know how to do that correctly. It looks fine when I print this list but when I run the script I get Error translating CommandLine and the debugging line is never executed.

4
  • already tried to without \" (no " in third arg)? Commented Jan 17, 2013 at 8:51
  • Yes, I've tried few quotas combinations (and also without them) Commented Jan 17, 2013 at 8:55
  • did you tried splitting the commands.append at space in your string ? Commented Jan 17, 2013 at 9:01
  • @Gcmalloc The "`" serve to protect the spaces, so splitting at the spaces seems inappropriate. Commented Jan 17, 2013 at 9:02

1 Answer 1

1

The quotas are only required for the shell executing the command.

If you do the said call directly from the shell, you probably do

mvn test -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE"

With these " signs you (simply spoken) tell the shell to ignore the spaces within.

The program is called with the arguments

mvn
test
-Dmaven.surefire.debug=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE

so

from subprocess import call
commands = []
commands.append("mvn")
commands.append("test")
commands.append("-Dmaven.surefire.debug=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE")
call(commands)

should be the way to go.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, it really works, I must have made a typo when I was trying it. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.